Do I need to DataBind twice?

  • Thread starter Thread starter Andy Fish
  • Start date Start date
A

Andy Fish

Hi,

I have a repeater nested within a repeater. After databinding the outer
repeater, I loop through the items and databind the inner repeaters, also
setting the inner repeater's ItemCommand event handler at the same time.

I have disabled viewstate for performance reasons.

Now, say the user clicks a control on one of the inner repeaters which
causes a postback. I need to databind in the page_Load() because otherwise
the event handlers don't get set up. After processing the action (which
updates the database) I need to databind again to get the new values
displayed.

I guess DataBind is quite an expensive operation. Is there an easy way to
avoid having to do it twice in the same postback?

TIA

Andy
 
Andy,
Seems like you are doing it right since you've disabled viewstate. The only
way I can think of is to violate clean .Net principals and use hidden form
fields to track values and Request.Form. This way you can bind originally,
have the page postback, read the values from Request.Form (instead of
rebinding) and then rebind the display the new values. This'll save you 1
bind....

Karl
 
Thanks Karl,

I've no wish to make it any more difficult than necessary, so I'll leave it
like it is. I just wanted a sanity check. :-)
 

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

Back
Top