選擇默認經由ASPX標記值:
<asp:RadioButtonList ID="radRiskLevel" runat="server" RepeatDirection="Horizontal">
<asp:ListItem Value="High" Selected="True">Select</asp:ListItem>
<asp:ListItem Value="Mid">Mid</asp:ListItem>
<asp:ListItem Value="Low">Low</asp:ListItem>
</asp:RadioButtonList>
通過C#代碼隱藏
選擇默認值:
if (!IsPostBack) // prevent from selecting default value during postback
{
if (radRiskLevel.SelectedIndex == -1) //-1 is the indication of none selected
{
radRiskLevel.SelectedIndex = 0; // the index of items in radiobutton in the list you want to select
//radRiskLevel.Items.FindByText("Select").Selected = true; //can also be selected by text, need to pass text name as parameter
//radRiskLevel.Items.FindByValue("High").Selected = true; //can also be selected by value, need to pass value name as parameter
}
}