N
Nofear
Hi all !
I saw many post on the SelectedIndexChanged event not being PostedBack
when the property AutoPostback is set to true.
In fact, i done many test and my conclusion is :
When you add Listitems to the RadioButtonList, the value of each
ListItem must be UNIQUE.
Try this
protected System.Web.UI.WebControls.Label lblInfo;
protected System.Web.UI.WebControls.RadioButtonList radBtnList;
private void Page_Load(object sender, System.EventArgs e)
{
if(! Page.IsPostBack)
{
radBtnList.Items.Add(new ListItem("Entry 01", "01"); <= SAME
radBtnList.Items.Add(new ListItem("Entry 02", "02");
radBtnList.Items.Add(new ListItem("Entry 03", "01"); <= SAME
radBtnList.Items.Add(new ListItem("Entry 04", "04");
radBtnList.Items.Add(new ListItem("Entry 05", "05");
}
}
private void radBtnList_SelectedIndexChanged(object sender,
System.EventArgs e)
{
lblInfo.Text = "L'élément sélectionné a pour valeur texte : " +
radBtnList.SelectedItem.Text;
}
Entries 1 and 3 will not postback correctly.
This version postback correctly, because all ListItem Values are
differents
radBtnList.Items.Add(new ListItem("Entry 01", "01");
radBtnList.Items.Add(new ListItem("Entry 02", "02");
radBtnList.Items.Add(new ListItem("Entry 03", "03");
radBtnList.Items.Add(new ListItem("Entry 04", "04");
radBtnList.Items.Add(new ListItem("Entry 05", "05");
I hope this will help.
Nofear
I saw many post on the SelectedIndexChanged event not being PostedBack
when the property AutoPostback is set to true.
In fact, i done many test and my conclusion is :
When you add Listitems to the RadioButtonList, the value of each
ListItem must be UNIQUE.
Try this
protected System.Web.UI.WebControls.Label lblInfo;
protected System.Web.UI.WebControls.RadioButtonList radBtnList;
private void Page_Load(object sender, System.EventArgs e)
{
if(! Page.IsPostBack)
{
radBtnList.Items.Add(new ListItem("Entry 01", "01"); <= SAME
radBtnList.Items.Add(new ListItem("Entry 02", "02");
radBtnList.Items.Add(new ListItem("Entry 03", "01"); <= SAME
radBtnList.Items.Add(new ListItem("Entry 04", "04");
radBtnList.Items.Add(new ListItem("Entry 05", "05");
}
}
private void radBtnList_SelectedIndexChanged(object sender,
System.EventArgs e)
{
lblInfo.Text = "L'élément sélectionné a pour valeur texte : " +
radBtnList.SelectedItem.Text;
}
Entries 1 and 3 will not postback correctly.
This version postback correctly, because all ListItem Values are
differents
radBtnList.Items.Add(new ListItem("Entry 01", "01");
radBtnList.Items.Add(new ListItem("Entry 02", "02");
radBtnList.Items.Add(new ListItem("Entry 03", "03");
radBtnList.Items.Add(new ListItem("Entry 04", "04");
radBtnList.Items.Add(new ListItem("Entry 05", "05");
I hope this will help.
Nofear