views:

25

answers:

0

I have below GridView that generates a PDF document. How do I add "valign = top" in all td's? also if the table moves to a new page in the PDF doc I want the table to be closed at the bottom of the previous page and start as new page with table headers added in the new page. Hope this is clear....

           GridView gridView = null;

            // Default to a GridView if no data control has been specified
            if (DataControlView == null)
                DataControlView = _gridView;

            gridView = DataControlView as GridView;
            if (gridView == null)
                throw new ApplicationException("Some Error");

            // Its necessary to add the DataControl to the
            // collection of child controls otherwise no content
            // will be generated. Remember not to add the DataControl
            // if its already there.
            if (!Controls.Contains(DataControlView))
                Controls.Add(DataControlView);


            if (Columns == null)
                gridView.AutoGenerateColumns = true;
            else
            {
                gridView.Columns.Clear();
                gridView.AutoGenerateColumns = false;

                foreach (PdfDataColumn col in Columns)
                {
                    BoundField boundField = new BoundField();
                    boundField.HtmlEncode = col.EncodeHtml;
                    boundField.HeaderText = col.ColumnTitle;
                    boundField.DataField = col.DataProperty;
                    gridView.Columns.Add(boundField);
                }

            }



            DataControlView.DataSource = DataSource;
            DataControlView.DataBind();