((Label)GridView1.Rows[0].FindControl("EFen")).Text)没有获取到值吗

1 0=1 2019-05-23 08:16:16
protected void Button1_ServerClick1(object sender, EventArgs e)
{
int WenJuanId = int.Parse(Request.QueryString["id"].ToString());
float fenshu =0;

float AFen = float.Parse(((Label)GridView1.Rows[0].FindControl("AFen")).Text);
float BFen = float.Parse(((Label)GridView1.Rows[0].FindControl("BFen")).Text);
float CFen = float.Parse(((Label)GridView1.Rows[0].FindControl("CFen")).Text);
float DFen = float.Parse(((Label)GridView1.Rows[0].FindControl("DFen")).Text);
float EFen = float.Parse(((Label)GridView1.Rows[0].FindControl("EFen")).Text);
foreach (GridViewRow dr in GridView1.Rows)
{
string str = "";
if (((RadioButton)dr.FindControl("RadioButton1")).Checked)
{
fenshu = fenshu + AFen;
}
else if (((RadioButton)dr.FindControl("RadioButton2")).Checked)
{
fenshu = fenshu + BFen;
}
else if (((RadioButton)dr.FindControl("RadioButton3")).Checked)
{
fenshu = fenshu + CFen;
}
else if (((RadioButton)dr.FindControl("RadioButton4")).Checked)
{
fenshu = fenshu + DFen;
}

else if (((RadioButton)dr.FindControl("RadioButton5")).Checked)
{
fenshu = fenshu + EFen;
}

}这个代码里面为什么累加没有结果值,是因为((Label)GridView1.Rows[0].FindControl("EFen")).Text)没有获取到值吗?
麻烦大家看一下,很急!!!!!
...全文
67 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
1 0=1 2019-05-23
  • 打赏
  • 举报
回复
不好意思 我是个新手 我还是不太明白 拆解是要怎么拆呀
OrdinaryCoder 2019-05-23
  • 打赏
  • 举报
回复
((Label)GridView1.Rows[0].FindControl("EFen")).Text)把这句拆解开 看哪块不对
1 0=1 2019-05-23
  • 打赏
  • 举报
回复
怎么调试呀 感觉应该是((Label)GridView1.Rows[0].FindControl("EFen")).Text)没有取到值 我把fenshu=DFen.tostring() 也是0
stherix 2019-05-23
  • 打赏
  • 举报
回复
没有报错说明取到值了 可能是选中的RadioButton对应的列值都是0 这个调试下就知道了
1 0=1 2019-05-23
  • 打赏
  • 举报
回复
是的 Text里面是有值的 但是累加出来结果=0
OrdinaryCoder 2019-05-23
  • 打赏
  • 举报
回复
累加没有结果是只fenshu = 0?

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧