PARDON1234 2014-11-08 14:54 采纳率: 0%
浏览 1838

求大神解答,为什么datalist中处理radiobutton的checked时string无法赋值?

代码如下,在最后if (strarm == tmp)判定时编译器老是提醒我tmp的值为空,不能比较,这是为什么呢?
string tmp;
RadioButton A = (RadioButton)DataList1.Items[i].FindControl("RA");
RadioButton B = (RadioButton)DataList1.Items[i].FindControl("RB");
RadioButton C = (RadioButton)DataList1.Items[i].FindControl("RC");
RadioButton D = (RadioButton)DataList1.Items[i].FindControl("RD");
Label showre = ((Label)DataList1.Items[i].FindControl("Label4"));
string strarm = ((Label)DataList1.Items[i].FindControl("Label3")).Text.Trim();
if (A.Checked)
{
tmp = "A";

        }
        else if (B.Checked)
        {
            tmp = "B";
        }
        else if (C.Checked)
        {
            tmp = "C";
        }
        else if (D.Checked)
        {
            tmp = "D";
        }
        if (strarm == tmp)//问题所在,提示tmp是null
        {
            score = score + 1;
        }
  • 写回答

1条回答

  • q107770540 2014-12-08 05:46
    关注

    你有DEBUG过你的代码么?

    评论

报告相同问题?

悬赏问题

  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件