Hi All,
It’s clear wehn I change any control and then posts back the SaveViewState method saves the changes and apply them agian after postback, see the folowing code notice that server-side-code put in a scrispt 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's 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 see my list fileed but when I select an item and push next button the SelectedItem property of the list remains null, what’s the reason??
Thanks All
I found the reason, the code script placed in .aspx file is called ‘code render block’, its executed during the render phase and after save view state phase so the changes done by this kind of code just renderd but not saved, as simple as that.