如何纠正我这个错误 [英] how to rectify i this error

查看:82
本文介绍了如何纠正我这个错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

RadioButtonList r = default(RadioButtonList);
		r = (RadioButtonList)v.FindControl("RadioButtonList1");
		r.Items.Clear();
		
       r.Items.Add(dt.Rows[ctr]["choice1"]);
       r.Items.Add(dt.Rows[ctr]["choice1"]);
        r.Items.Add(dt.Rows[ctr]["choice3"]);
        r.Items.Add(dt.Rows[ctr]["choice4"]);
       dt.Rows[ctr]["selected"]=r.SelectedIndex;

        



		Session["ctr"] = ctr;
	}


我收到错误r.Items.Add(dt.Rows [ctr] ["choice1"]);


感谢您的宝贵重播.


I got the error r.Items.Add(dt.Rows[ctr]["choice1"]);


Thank u for your valuable replay

推荐答案

它们的代码可能有多个问题.

我几乎看不到如下.

1)RadioButtonList的Delcare对象,如下所示.
Their can be multiple issues with your code.

Few which I can see are as below.

1) Delcare object of RadioButtonList as below.
RadioButtonList r = new RadioButtonList();



2)在添加Items时使用以下语法.



2) Use below syntax while adding Items.

r.Items.Add(dt.Rows[ctr]["choice1"].ToString());



还要调试代码,并检查您的dt不是null并在其中包含行.



Also debug your code and check your dt is not null and has Rows in it.


这篇关于如何纠正我这个错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆