i have a gridview
' /> Total
my code behind :
protected void btnGetTotal_Click(object sender, EventArgs e)
{
int Rowindex = 0;
StringCollection sc = new StringCollection();
if (ViewState["CurrentTable"] != null)
{
DataTable dtCurrenttable = (DataTable)ViewState["CurrentTable"];
if (dtCurrenttable.Rows.Count > 0)
{
for (int i = 1; i <= dtCurrenttable.Rows.Count; i++)
{
TextBox txtFeesAmount = (TextBox)gvSales.Rows[Rowindex].Cells[1].FindControl("txtAmount");
Total += Convert.ToInt32( txtFeesAmount.Text);
tostring= Total.ToString();
tostring = ((TextBox)gvSales.FooterRow.FindControl("txtTotal")).Text;
}
}
}
}
The values in the taxtbox are added and while display in footer template it is not assinging with the added value. it gives me error:
object referrence not set to instance of object.
How to assign the value(total values added from each textbox) to the'txtTotal' Textbox in gridview
i.e in this line
tostring = ((TextBox)gvSales.FooterRow.FindControl("txtTotal")).Text;