proginc
asked on
Footer data GridView
I am looping through a GridView to obtain Row, footer and header data. I can check the status of the DataControlRowType and get the rows, but cannot seem to get the footer.
<asp:TemplateField HeaderText="Amount" FooterStyle-Font-Bold="True" SortExpression="Amount">
<ItemTemplate>
<asp:Label ID="lblAmount" runat="server" Text='<%# GetAmount(decimal.Parse(Eval("Amount").ToString()))%>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="lblTotalAmount" runat="server" Text='<%# GetTotalAmount().ToString()%>'></asp:Label>
</FooterTemplate>
<FooterStyle Font-Bold="True" />
</asp:TemplateField>
This fails in code behind:
foreach (GridViewRow row in this.gridView.Rows)
{
if (row.RowType == DataControlRowType.DataRow)
{
if( row.RowType == DataControlRowType.Footer)
{
}
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
rpkhare's suggestion goes straight to the footer row to find the control.
You don't need to loop through all of the rows to identify which one is the header row and which one is the footer row. There is only one header row and one footer row so you can access those rows specifically as rpkhare has suggested -
GridViewRow row = GridView1.FooterRow
Bear in mind also that header and footer rows cannot be data-bound.
You don't need to loop through all of the rows to identify which one is the header row and which one is the footer row. There is only one header row and one footer row so you can access those rows specifically as rpkhare has suggested -
GridViewRow row = GridView1.FooterRow
Bear in mind also that header and footer rows cannot be data-bound.
ASKER