472,803 Members | 979 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,803 software developers and data experts.

The problem with DataBind

Say you are creating a page which contains a child control which uses a
DataList or DataGrid control. In a DataList, the rows are dynamic
controls and are data bound, so you have to first load the data source
and then DataBind. The problem arises when the containing Page calls
DataBind before your child control, say in their Page_Load. So you
have a Page with Page_Load calling DataBind and a child control with a
Page_Load and a DataBind.

What happens, I have found, is that on a PostBack, the DataBind is
broadcasted to your child control just after the ViewState is loaded
but before we get to start the child control's Page_Load. Thus, the
DataBind causes the child control to disappear because we bound before
we got to execute the event handler for the PostBack.

Does this make sense? I have solved this problem by overriding
DataBind, but it made me think. Can't all child controls be messed-up
by this problem of a DataBind in a parent control or page? As such,
should all controls override DataBind?

Thanks for your thoughts!

Dec 29 '06 #1
0 1006

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: autofill | last post by:
2 scenario inside a WebUserControl. I want to know why Microsoft and so many book doesn't suggest us to work like that. This control going to be in my page and I will call the DataBind of my...
by: Joel Reinford | last post by:
I am attempting to verify whether a datareader is closed by calling the databind on a control. for example (fake code) Dim rdr as SqlDataReader rdr = mycommand.executeReader... ...
by: Martin | last post by:
Hi, I've got a web label control which I set a databind expression on the Text attribute in the html for the page (aspx file). At runtime, I want to override this attribute, so before I do...
by: Vaidas Gudas | last post by:
I am getting this error: System.Web.UI.WebControls.ListControl.PerformDataBinding(IEnumerable dataSource) +970 System.Web.UI.WebControls.ListControl.OnDataBinding(EventArgs e) +80...
by: Roy | last post by:
This may seem silly, but I'm just curious... I've noticed that in the code-behind, asp:Label has the .DataBind property yet has NO corresponding .DataSource property? Am I missing something? How...
by: Eric Liprandi | last post by:
Hi, I am trying to call the DataBind() function of a ContentPlaceHolder control from a Master page. It worked fine on my first page, using "standard" forms and grids. I had not overidden the...
by: Mike Collins | last post by:
I someone can please help, I am about at an end in trying to figure this out. I am adding some dynamic controls to my page (I found out that I was supposed to be doing that in the oninit event,...
by: DC | last post by:
The Code <%@ import namespace="System" %> <%@ import namespace="System.Web" %> <%@ import namespace="System.Web.UI" %> <%@ import namespace="System.Web.UI.HtmlControls" %> <%@ import...
by: DC | last post by:
The problem I'm using the .NET GridView and FormView objects for the first time and im getting the error "An OleDbParameter with ParameterName '@ID' is not contained by this...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.