选定的radiobuttonlist索引属性 [英] selected index property of radiobuttonlist

查看:90
本文介绍了选定的radiobuttonlist索引属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个在线考试项目。对于选项,我采用了radiobutton列表并动态绑定它。

问题是当我使用radiobuttonlist的选定索引属性时,它没有给出选择选项时的正确值。

这是代码背后的代码:





 sql =  从Contact2中选择Question_no,Question,Option1,Option2,Option3,Option4,Question_Image,其中Question_no = + nextq +  ; 
ds = cn.SelectDS(sql);
if (ds.Tables [ 0 ]。Rows.Count > 0
{

lblqno.Text = ds.Tables [ 0 ]。行[ 0 ] [ Question_no]的ToString();
lblqstn.Text = ds.Tables [ 0 ]。行[ 0 ] [ 问题]。ToString();
RadioButtonList1.ClearSelection();
RadioButtonList1.Items.Clear();
RadioButtonList1.Items.Add(ds.Tables [ 0 ]。行[ 0 ] [ Option1]。ToString());
RadioButtonList1.Items.Add(ds.Tables [ 0 ]。行[ 0 ] [ Option2]。ToString());
RadioButtonList1.Items.Add(ds.Tables [ 0 ]。行[ 0 ] [ Option3]。ToString());
RadioButtonList1.Items.Add(ds.Tables [ 0 ]。行[ 0 ] [ Option4]。ToString());
Image1.ImageUrl = ds.Tables [ 0 ]。行[ 0 ] [ Question_Image]。ToString();
}


请帮帮我

解决方案

将RadioButtonList的AutoPostBack属性设置为真。

I am developing a online exam project. For the option i took a radiobutton list and binding it dynamically.
The problem is that when i use the selected index property of radiobuttonlist, it is not giving it correct value on selecting a option.
Here is my code behind code:


sql = "select Question_no,Question ,Option1,Option2,Option3,Option4,Question_Image from Contact2 where Question_no=" + nextq + "";
            ds = cn.SelectDS(sql);
            if (ds.Tables[0].Rows.Count > 0)
            {

                lblqno.Text = ds.Tables[0].Rows[0]["Question_no"].ToString();
                lblqstn.Text = ds.Tables[0].Rows[0]["Question"].ToString();
                RadioButtonList1.ClearSelection();
                RadioButtonList1.Items.Clear();
                RadioButtonList1.Items.Add(ds.Tables[0].Rows[0]["Option1"].ToString());
                RadioButtonList1.Items.Add(ds.Tables[0].Rows[0]["Option2"].ToString());
                RadioButtonList1.Items.Add(ds.Tables[0].Rows[0]["Option3"].ToString());
                RadioButtonList1.Items.Add(ds.Tables[0].Rows[0]["Option4"].ToString());
                Image1.ImageUrl = ds.Tables[0].Rows[0]["Question_Image"].ToString();
            }


Please help me

解决方案

Set AutoPostBack property of RadioButtonList to True.


这篇关于选定的radiobuttonlist索引属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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