[SOLVED] GridView HeaderRow.TableSection error

Issue

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

Thank you,

Solution

First you should set type of the first row to header when it will created :

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

    }
}

Now You Can Do this :

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

Answered By – S.A.Parkhid

Answer Checked By – Marie Seifert (BugsFixing Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *