要设置RadioButtonList的默认选项,您可以使用SelectedIndex属性。首先,确保您已经为RadioButtonList中的每个RadioButton设置了Value属性,然后通过将SelectedIndex属性设置为对应RadioButton的索引来选择默认选项。
以下是一个简单的示例:
<asp:RadioButtonList ID="RadioButtonList1" runat="server"> <asp:ListItem Text="Option 1" Value="1" /> <asp:ListItem Text="Option 2" Value="2" /> <asp:ListItem Text="Option 3" Value="3" /> </asp:RadioButtonList> <asp:Button ID="btnSubmit" runat="server" OnClick="btnSubmit_Click" Text="Submit" /> Page_Load事件处理程序中)设置默认选项:protected void Page_Load(object sender, EventArgs e) { // 设置默认选项,例如,选择"Option 2" RadioButtonList1.SelectedIndex = 1; } 在这个例子中,当页面加载时,"Option 2"将被设置为默认选项。当用户点击"Submit"按钮时,服务器端代码将处理所选选项。