I've built a few UserControls that have worked perfectly for a while. Now,
for the first time, I want to use these controls inside a Data-Bound Repeater
control.
When the page first loads, my control works perfectly. But any kind of
PostBack results in runtime errors in the control's PageLoad(), when it tries
to do
SomeProperty = ViewState["SomeProperty"].ToString()
where it says that there's a NULL Exception (I guess that this means that
the value of my ViewState["SomeProperty"] is NULL.
Perhaps you can help me understand how things change in the situation where
my control is inside a Repeater so that I can try to figure out why this is
happening?
Thanks.
Alex
Hello Alex,
Thank you for posting.
Is this usercontrol you're developing still the one over mentioned in your
former threads? As for hosted in databinding repeater control scenario, the
only difference is that when the repeater control is performing
databinding( repeater.DataBind method is called), it will populae
repeaterItems and perform databinding on all the sub controls in each
repeaterItem(include your usercontrol if it is put in the repeater
control). Also, since your ascx usercontrol has its own databinding (in
page_load ) code logic, it may conflict with page's databinding (when the
repeater.dataBind cause the usercontrol in repeaterItem to databind ).
Generally, I would change the original databinding code into the "DataBind"
override method in my usercontrol. e.g.
========in ascx code behind======
public override void DataBind()
{
base.DataBind();
PerformDataBind();
}
==============
PerformDataBind() is the method which encapsulate the code to query
database and populate the dropdownlist ....
As for the ViewState error you mentioned, I think it's a control specific
problem, would you provide your current version of the usercontrol so that
I can have a look on it?
Regards,
Steven Cheng
Microsoft MSDN Online Support Lead
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Signature
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Steven Cheng[MSFT] - 15 Jun 2006 14:08 GMT
Hi Alex,
How are you doing on this issue, have you got any further progress? Please
don't hesitate to let me know if you need any help on this.
Regards,
Steven Cheng
Microsoft MSDN Online Support Lead
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Signature
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)