The table must contain row sections in order of header, body, then footer.

20 July 2022 | Viewed 2659 times

This is a common exception when you use PagerSettings to GridView in asp.net. Pager Settings Position is trying to generate a Pager above the head or below the footer or both.

here is GridView Settings

Code
AllowPaging="true"
PagerSettings-Position="Bottom"
PagerSettings-Mode="NumericFirstLast"

Exception: The table must contain row sections in order of header, body, then footer.

To resolve this issue, you also have to set those Pagers to have be TableRowSection.TableHeader and TableRowSection.TableFooter respectively in order to have a pager in the header and footer.

Add "DataBound" event to Gridview and use below code

C# Code
protected void GridView1_DataBound(object sender, EventArgs e)
{
GridView1.UseAccessibleHeader = true;
GridView1.HeaderRow.TableSection = TableRowSection.TableHeader;

if (GridView1.TopPagerRow != null)
GridView1.TopPagerRow.TableSection = TableRowSection.TableHeader;

if (GridView1.BottomPagerRow != null)
GridView1.BottomPagerRow.TableSection = TableRowSection.TableFooter;
}




PreviousNext