I can't see my dynamically created RadioButtonList or CheckBoxList objects after postback
Hello to all,
It is clear that I change any control and then go back the SaveViewState method saves the changes and applies them agian after postback, see the following post about server side code being scripted in my code. liske this <%%>
switch (myQuestion.QuestionType)
{
case 0:
{
rdlistAnswers.Items.Clear();
foreach (sting item in myCollection)
{
ListItem i = new ListItem();
i.Value = item;
i.Text = item;
rdlistAnswers.Items.Add(i);
}
**//the folowing line of code is not a comment, it a tag for asp control
//but I commeted it due to editing requirements**
//<asp:RadioButtonList ID="rdlistAnswers" runat="server"</asp:RadioButtonList>
break;
}
case 1:
{
cblistAnswers.Items.Clear();
foreach (sting item in myCollection)
{
ListItem i = new ListItem();
i.Value = item;
i.Text = item;
cblistAnswers.Items.Add(i);
}
<asp:CheckBoxList ID="cblistAnswers" runat="server" </asp:CheckBoxList>
}
}
Now . I can view the list, but when I select an item and click the next button, the SelectedItem property of the list remains null , which is the reason
+1
source to share
3 answers