How to print a GridView title on every print page

How to print the page title and title GridViewon each print page?

I want to add a page title and a title GridViewon each page.

I used a page break to break GridViewinto several pages, but only the first page comes with a heading, and all the rest without a title and a cover page.

For dynamic GridViewmy code uses AutoGenerateColumns="true".

+5
source share
1 answer

Put lower in the head

<style media="print">

                .MyCssClass thead
                {
                    display: table-header-group;
                }

</style>

Now put your gridview in a div and give the div the class name MyCssClass

GridView1_RowDataBound , Gridview.

private void MakeGridViewPrinterFriendly(GridView gridView)
        {
            if (gridView.Rows.Count > 0)
            {
                gridView.UseAccessibleHeader = true;
                gridView.HeaderRow.TableSection = TableRowSection.TableHeader;
                //gridView.HeaderRow.Style["display"] = "table-header-group";
            }
        }

IE FF. Chrome.

+4

All Articles