【问题标题】:ASP.NET Set RadioButton to Select by a String ValueASP.NET 将 RadioButton 设置为按字符串值选择
【发布时间】:2019-11-01 23:49:35
【问题描述】:

我有一个带有3 按钮的RadioButton 控件。

我正在从 SharePoint 列表中检索一个值,并根据检索到的值选择 RR 控件。

以下哪项是正确的使用方法?

ResignationTypeRBList.SelectedValue = _request.ResignationType;
ResignationTypeRBList.SelectedItem  = _request.ResignationType;
ResignationTypeRBList.SelectedIndex = _request.ResignationType;

  <asp:RadioButtonList ID="ResignationTypeRBList" RepeatDirection="Horizontal" runat="server" CausesValidation="false">
        <asp:ListItem Text="Resignation" Value="Resignation" Selected="True"></asp:ListItem>
        <asp:ListItem Text="NPL" Value="NPL"></asp:ListItem>
        <asp:ListItem Text="Others" Value="Others"></asp:ListItem>
    </asp:RadioButtonList>

谢谢

【问题讨论】:

  • 当你试用它们时会发生什么?

标签: asp.net radio-button


【解决方案1】:

如果您从 Sharepoint 列表中获取值,则将其分配给 SelectedValue

ResignationTypeRBList.SelectedValue = "NPL";

【讨论】:

    猜你喜欢
    • 2013-06-06
    • 2022-01-06
    • 2014-05-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-28
    • 2014-02-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多