O
Oleg
Hi,
Can anyone please clarify why Repeater does not maintain its viewstate when
the base.DataBind() call is made on Page_Load.
Example that illustrates this problem is here:
1. protected void Page_Load(object sender, EventArgs e) {
2.
3. base.DataBind();
4.
5. if (!IsPostBack) {
6. string[] source = new string[] { "1", "2", "3" };
7. ddlTest.DataSource = source;
8. ddlTest.DataBind();
9.
10. rptTest.DataSource = source;
11. rptTest.DataBind();
12.
13. }
14.
15. }
When the page goes through the postabck DropDownList maintain its state, but
repeater is not.
Removing base.DataBind(); on line 3 solves the problem.
Why is this difference between the DropDownList and Repeater?
Does this problem means that Repeater needs to be DataBound on both PostBack
and !Postback ?
The only reason I have base.DataBind() on the page is to void this error
"The Controls collection cannot be modified because the control contains
code blocks (i.e. <% ... %>)"
This is because I have following validation code on aspx page
1. var ddl = document.forms[0].<%#ddlTest.ClientID%>;
Thanks in advance,
Oleg
Can anyone please clarify why Repeater does not maintain its viewstate when
the base.DataBind() call is made on Page_Load.
Example that illustrates this problem is here:
1. protected void Page_Load(object sender, EventArgs e) {
2.
3. base.DataBind();
4.
5. if (!IsPostBack) {
6. string[] source = new string[] { "1", "2", "3" };
7. ddlTest.DataSource = source;
8. ddlTest.DataBind();
9.
10. rptTest.DataSource = source;
11. rptTest.DataBind();
12.
13. }
14.
15. }
When the page goes through the postabck DropDownList maintain its state, but
repeater is not.
Removing base.DataBind(); on line 3 solves the problem.
Why is this difference between the DropDownList and Repeater?
Does this problem means that Repeater needs to be DataBound on both PostBack
and !Postback ?
The only reason I have base.DataBind() on the page is to void this error
"The Controls collection cannot be modified because the control contains
code blocks (i.e. <% ... %>)"
This is because I have following validation code on aspx page
1. var ddl = document.forms[0].<%#ddlTest.ClientID%>;
Thanks in advance,
Oleg