473,386 Members | 1,886 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 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!
NL

Dec 29 '06 #1
0 1034

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

Similar topics

0
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...
5
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... ...
1
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...
0
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...
2
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...
0
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...
0
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,...
2
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...
0
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.