GridView HeaderRow.TableSection Error

I have a bad error when setting the GridViews HeaderRow.TableSection to TableRowSection.TableHeader: the table should contain sections of the rows in the order of the header, body, and then the footer. Please note that I do this in the grids of the DataBound event handler, and I DO NOT use paging. How can it be?

Thanks,

+2
source share
1 answer

First you must set the type of the header of the first line when it is created:

protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowIndex == 0) { e.Row.RowType = DataControlRowType.Header; } } 

Now you can do it:

  GridView1.DataSource = dt; GridView1.DataBind(); GridView1.HeaderRow.TableSection = TableRowSection.TableHeader; 
+1
source

All Articles