Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Repeater DataBinding

Reply
Thread Tools

Repeater DataBinding

 
 
Oleg
Guest
Posts: n/a
 
      09-25-2009
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
 
Reply With Quote
 
 
 
 
Adrienne Boswell
Guest
Posts: n/a
 
      09-25-2009
Gazing into my crystal ball I observed =?Utf-8?B?T2xlZw==?=
<> writing in
news:7E8E6567-8F72-4184-BE54-:

> 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.
************************************************** ****************




--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Databinding expressions are only supported on objects that have a DataBinding event jobs ASP .Net 0 09-25-2007 11:54 PM
Gridview encoding, or how to run commands before gridview's default databinding, or, how do I disable default databinding at all? Sergei Shelukhin ASP .Net 1 11-12-2006 01:43 PM
XML DataBinding to the Repeater Control; =?Utf-8?B?THVkbWFs?= ASP .Net 0 04-05-2004 04:21 PM
DataGrid Custom Column Error when DataBinding "does not contain a definition for 'DataBinding'" Earl Teigrob ASP .Net Datagrid Control 1 03-01-2004 04:52 AM
Nested repeater databinding question Ed Allan ASP .Net 0 08-01-2003 01:10 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57