asp.net,c#.net gridview页脚问题

时间:2011-08-05 05:56:32

标签: asp.net footer

我在网页上有一个gridview <asp:GridView ID="grid_search" runat="server" >

并且它包含“列”总值的页脚

我在Gridview中有一个列名生产值

prod_val nvarchar(50)

对于数据绑定我使用

背后的代码

protected void grid_search_RowDataBound(object sender, GridViewRowEventArgs e)     {         if (e.Row.RowType == DataControlRowType.DataRow) {

        `tot_prodVal = tot_prodVal + Convert.ToDecimal(e.Row.Cells[2].Text);`

} }

但它在调试时显示错误

System.FormatException:输入字符串的格式不正确。

PLZ给我解决方案..

1 个答案:

答案 0 :(得分:0)

由于你在问题中提到了页脚,我猜你想在页脚中执行该操作。所以你的if条件应该是

e.Row.RowType == DataControlRowType.Footer

我猜是因为你在条件中使用DataRow,e.Row.Cells [2] .Text并没有真正指向你想要它的字段。

相关问题