开发者

How to assign the value(total values added from each textbox) to the 'txtTotal' Textbox in gridview

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 开发者_JAVA百科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;


do like this :

grdList.Columns[2].FooterText = sumDebit.ToString();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜