Repeater DataBinding

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
 
A

Adrienne Boswell

Gazing into my crystal ball I observed =?Utf-8?B?T2xlZw==?=
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:

To quote Bob Barrows:
***canned wrong-newsgroup reply************************
There was no way for you to know it (except maybe by browsing through
some of the previous questions in this newsgroup before posting yours -
always a recommended practice) , but this is a classic (COM-based) asp
newsgroup.
ASP.Net bears very little resemblance to classic ASP so, while you may
be lucky enough to find a dotnet-knowledgeable person here who can
answer your question, you can eliminate the luck factor by posting your
question to a group where those dotnet-knowledgeable people hang out. I
suggest microsoft.public.dotnet.framework.aspnet or the forums at
www.asp.net.
******************************************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top