【问题标题】:I have to make Radio button as checked in C#?我必须在 C# 中检查单选按钮吗?
【发布时间】: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


【解决方案1】:

以后在 Visual Studio 中使用表单。

【讨论】:

    猜你喜欢
    • 2019-04-05
    • 2019-05-29
    • 1970-01-01
    • 2016-04-17
    • 2023-04-07
    • 2019-01-15
    • 1970-01-01
    • 1970-01-01
    • 2021-02-22
    相关资源
    最近更新 更多