gridview有radioButton [英] gridview Having radioButton

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

问题描述

我在Gridview项目模板中使用RadioButtons。我可以从radiobutton获取值,如果选择了一个单选按钮,则检查3个radiobutton的其余部分= false。

这是对于每一行。



关注Deepak

I am Using a RadioButtons inside the Gridview item template.how can i got the values from radiobutton and if one radio button is selected then rest of the 3 radiobuttons are checked=false.
this is for each row.

Regards Deepak

推荐答案

protected void GridView1_RowDataBound(object sender,GridViewRowEventArgs e)

{

标签x =(标签)e.Row.FindControl(lbl_QuestionID);

foreach(this.GridView1中的GridViewRow行。行)

{

if(e.Row.RowType == DataControlRowType.DataRow)

{

试试

{

List< OptionMasters> TheOptionMasters = new List< OptionMasters>();



RadioButton button =(RadioButton)e.Row.FindControl(RadioButton4);

RadioButton button1 =(RadioButton)e.Row.FindControl(RadioButton5);

RadioButton button2 =(RadioButton)e.Row.FindControl(RadioButton6);

RadioButton button3 =(RadioButton)e.Row.FindControl(RadioButton7);



TheOptionMasters = FeedbackMasterManagement.GetInstance.GetOptionMastersList();



PageVariables.ThisOptionMasters =(来自TheOptionMasters中的xyz

其中xyz.QuestionID == int.Parse(x.Text)

select xyz)。单();





button.Text = Pa geVariables.ThisOptionMasters.Option1;

button1.Text = PageVariables.ThisOptionMasters.Option2;

button2.Text = PageVariables.ThisOptionMasters.Option3;

button3.Text = PageVariables.ThisOptionMasters.Option4;



}

catch(exception ex)

{< br $> b $ b

抛出ex;

}

}



}

}



之后如何获得选择的radiobuttouns的值以及如何检查false另外3个按钮



deepak ...
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
Label x = (Label)e.Row.FindControl("lbl_QuestionID");
foreach (GridViewRow row in this.GridView1.Rows)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
try
{
List<OptionMasters> TheOptionMasters = new List<OptionMasters>();

RadioButton button = (RadioButton)e.Row.FindControl("RadioButton4");
RadioButton button1 = (RadioButton)e.Row.FindControl("RadioButton5");
RadioButton button2 = (RadioButton)e.Row.FindControl("RadioButton6");
RadioButton button3 = (RadioButton)e.Row.FindControl("RadioButton7");

TheOptionMasters = FeedbackMasterManagement.GetInstance.GetOptionMastersList();

PageVariables.ThisOptionMasters = (from xyz in TheOptionMasters
where xyz.QuestionID == int.Parse(x.Text)
select xyz).Single();


button.Text = PageVariables.ThisOptionMasters.Option1;
button1.Text = PageVariables.ThisOptionMasters.Option2;
button2.Text = PageVariables.ThisOptionMasters.Option3;
button3.Text = PageVariables.ThisOptionMasters.Option4;

}
catch (Exception ex)
{

throw ex;
}
}

}
}

after that how can i get values form radiobuttouns which is selected and how to checked false another 3 buttons

deepak...


单选按钮具有名为GroupName的默认属性。



它做什么?它只允许在该组中选择一个无线电。
Radio Button has default property called GroupName.

What it does?? It allows only one radio to get select at time in that group.


这篇关于gridview有radioButton的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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