DataBind issue

  • Thread starter Tomislav Bartolin
  • Start date
T

Tomislav Bartolin

Hi,

I have an aspx page which contains an ascx user control.
I am using Page.DataBind in Page_Load event of the page to bind elements to
page properties.
The problem is the ascx uses its Page_Load event to create objects which are
then used
for data binding, but because I call Page.DataBind in the parent page, the
ascx Page_Load event doesn't complete and its objects are null
references, so I get errors.
I have found a workaround for this issue, by using Page_PreRender event do
call Page.DataBind so that the ascx Page_Load event can complete.
I am wondering if this solution is ok,
and is there a way to prevent data binding of some page child controls when
Page.DataBind is called?

Thanks,
 
A

aa7im

Can you make the objects the .ASCX control load in OnInit instead on
OnLoad... It better to add controls to the control tree during Init()
anyway....

Then everything should work correctly
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top