【发布时间】:2017-10-06 05:41:06
【问题描述】:
我必须在 C# 后面的代码中检查单选按钮。 我尝试了下面的代码,但这不起作用。
RadioButtonList active =(RadioButtonList)editItem.FindControl("radbtnProfileName");
if(valueres.Select(i => i.profile).FirstOrDefault()) //this is the value(column) I am getting from the SP
{
active.SelectedValue = "Yes";
}
else
{
active.SelectedValue = "No";
}
【问题讨论】:
-
active.Checked=true? -
你试过
active.Selected = true; -
我试过 active.Checked=true & active.Selected = true;但它是说 RadioButtonList 不包含检查的定义,并且没有扩展方法“检查”接受“System.Web.UI.WebControls.RadioButtonList”类型的第一个参数。
-
你试过
active.SelectedIndex = x;,其中x是yes/no相应控件的索引吗? -
RadiobuttonList 甚至不是一个 winforms/wpf 控件,也许标记你正在使用的东西?
标签: c# webforms radio-button