在ASP.NET中,要设置RadioButtonList的默认选中项,可以使用以下方法:
SelectedValue属性:<asp:RadioButtonList ID="RadioButtonList1" runat="server" SelectedValue="2"> <asp:ListItem Value="1">选项1</asp:ListItem> <asp:ListItem Value="2">选项2</asp:ListItem> <asp:ListItem Value="3">选项3</asp:ListItem> </asp:RadioButtonList> 在这个例子中,SelectedValue属性被设置为"2",因此默认选中的项是"选项2"。
SelectedValue属性:protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { RadioButtonList1.SelectedValue = "2"; } } 在这个例子中,我们在Page_Load事件处理程序中设置SelectedValue属性。请注意,我们只在非回发请求(!Page.IsPostBack)时设置该属性,以避免在用户提交表单后重置选中项。
通过以上任一方法,您都可以设置RadioButtonList的默认选中项。