0
제목에 쓴 것처럼 코드 숨김은 RadioButton의 선택을 변경하려고 할 때 잘못된 값을 가져옵니다.코드 숨김이 잘못된 RadioButton 값을 가져옴
Dilemma.aspx :
<asp:RadioButtonList ID="rbList" runat="server">
<asp:ListItem Text="Yes, please." />
<asp:ListItem Text="No, thanks." />
<asp:ListItem Text="Ummm... maybe." />
</asp:RadioButtonList>
<asp:Button ID=""btnChoose" runat="server" text="OK" OnClick="btnChoose_Click" />
Dilemma.aspx.cs 대신 새로 선택의 RadioButton을 얻기의
protected void Page_Load(object sender, EventArgs e)
{
int initialIndex = GetInitialIndex(); // Simplified for sake of question.
rbList.SelectedIndex = initialIndex; // This works.
}
protected void btnChoose_Click(object sender, EventArgs e)
{
int selection = rbList.SelectedIndex; // This gets it wrong!
}
는 코드 숨김 여전히 선택 믿고 index는 초기 색인입니다.
왜?