简体   繁体   English

RadioButtonList从类中选择值

[英]RadioButtonList select value from class

I have RadioButtonList1 with item "Accept" and "Reject" as shown in code 我的RadioButtonList1带有项目“ Accept”和“ Reject”,如代码所示

 <tr>
        <td width="30%">
            <b>Status:</b>
        </td>
        <td>
            <asp:RadioButtonList ID="RadioButtonList1" runat="server" 
                RepeatDirection="Horizontal" AutoPostBack="True">
                <asp:ListItem Value="lAccept">Accept</asp:ListItem>
                  <asp:ListItem Value="lReject">Reject</asp:ListItem>
            </asp:RadioButtonList>
             <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ControlToValidate="RadioButtonList1"  TargetControlID="RadioButtonList1"  ErrorMessage="Status is Required" ForeColor="Red"></asp:RequiredFieldValidator>  </td>

Now in back end i want to select Reject automatically inside the below condition. 现在在后端,我想在以下情况下自动选择“拒绝”。

  if ((RQ >= 2 && RQ <= 8) && RejQ>0)
    {

    }

How i will select value of RadioButtonList1 in class? 我将如何在类中选择RadioButtonList1的值? Thanks in Advance for your help. 在此先感谢您的帮助。

This will select the given index. 这将选择给定的索引。 Write this line in Page_Load event to select it automatically!! 在Page_Load事件中编写此行以自动选择它!

RadioButtonList1.Items[1].Selected = true;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM