【问题标题】:asp.net,c#.net grid view footer problemasp.net,c#.net 网格视图页脚问题
【发布时间】:2011-10-20 14:09:16
【问题描述】:

我在网页中有一个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:输入字符串的格式不正确。

请给我解决方案..

【问题讨论】:

  • 请显示prod_val列的标记

标签: asp.net footer


【解决方案1】:

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

e.Row.RowType == DataControlRowType.Footer

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

【讨论】:

  • 在我的 (c#) asp.net 网站中,我们允许用户使用 id 和密码登录,我想在另一个网页中查看活动(在线)用户。
猜你喜欢
  • 2012-09-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-11-23
相关资源
最近更新 更多