我无法从单选按钮列表中获取单选按钮以在 IF 语句中被选中。当 IF 为真时,其他一切都正常工作,除了这个。Request Pending 是默认值,但是当 IF 为 True 时,我需要能够选择“Waiting for Approval”按钮。
我的 HTML 代码是:
<asp:RadioButtonList ID="rbGiftStatus" RepeatDirection="Horizontal"
runat="server" TabIndex="3">
<asp:ListItem Text="Request Pending" Selected="True" Value="1"></asp:ListItem>
<asp:ListItem Text="Check Pending" Value="2"></asp:ListItem>
<asp:ListItem Text="Completed" Value="3"></asp:ListItem>
<asp:ListItem Text="Waiting for Approval" Value="4"></asp:ListItem>
</asp:RadioButtonList>
我的 C# 是这样的:
rbGiftStatus.SelectedIndex = 4;
我尝试了其他方法,例如:
rbGiftStatus.Text = "4";
rbGiftStatus.SelectedItem = "4";
rbGiftStatus.SelectedValue = "4";
它们似乎都不起作用,我不知道为什么