ASP.NET 设置单选按钮以按字符串值进行选择



我有一个带有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>

谢谢

如果要从 SharePoint 列表中获取值,请将其分配给 SelectedValue

ResignationTypeRBList.SelectedValue = "NPL";

最新更新