Click here to Skip to main content
15,902,634 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my asp.net web application i want to get gridview footer value in code side
my design code of footer
XML
<asp:BoundField DataField="Amount" DataFormatString="{0:N2}"
                                        HeaderText="Amount">
                                        <FooterStyle HorizontalAlign="Right" />
                                        <ItemStyle HorizontalAlign="Right" />
                                    </asp:BoundField>

that footer contain net amount iwant to get that value here'
C#
protected void ibtnSave_Click(object sender, EventArgs e)
       {

decimal Discount = 0, Freight = 0, OtherExpense = 0, NetAmount = 0, CurrencyRate = 0;
NetAmount =.... here i want to get netamount from that footer

please help me
Posted
Updated 19-Aug-11 20:17pm
v2

1 solution

Check this :

http://www.asp.net/data-access/tutorials/displaying-summary-information-in-the-gridview-s-footer-cs[^]

Now, when you want to fetch the value from the footer row use the below method :

C#
protected void btnGo_Click(object sender, EventArgs e)
{
        txtTotal.Text = Gridview1.FooterRow.Cells[0].Text;
}
 
Share this answer
 
v3
Comments
Shibiny 5-Sep-11 6:59am    
i Change my code
<asp:TemplateField HeaderText="Amount" >
<itemtemplate>
<asp:Label ID="lblAmount" runat="server" Text='<%# Eval("Amount") %>'>


<footertemplate>
<asp:Label ID="lblTotal" runat="server" >





////////////////
Label lblTotal = ((Label)gvDetail.FooterRow.FindControl("lblTotal"));
NetAmount= Convert.ToDecimal(lblTotal.Text);



but in NetAmount only get the footer value at the time of loading grid,

if change the footer value ,only get the older value

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900