By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,089 Members | 1,952 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,089 IT Pros & Developers. It's quick & easy.

Databinding Expressions & Page Rendering Sequence

P: n/a
Ive got the basic idea behind DataBinding Expressions, but I have a couple
of questions, Ok its four actually :)

Q1.) It would appear that if you use Page.DataBind that all child controls
and the page get bound to their respective DataSources, is this correct ?
and if so why would you need to individually bind controls, why not jsut use
Page.DataBind everytime?, Im sure there is a good reason why not but I cant
think of one at the moment.

Q2.) The phase Container.DataItem seems to be able to appear either on its
own or within the DataBinder.Eval static function. I cant seem to find a
cohesive paper on the net that really explains well the Container.DataItem,
and where and how it should be used.

So far I have been able to bind stuff like a class level variable called
page title and have that display in a reapeater header template and also
bind things like arrays to the repeater and this works fine. But as the
array does not have a propertyname using DataBinder.Eval does not work, you
need to use Container.DataItem

Q3.) When are the DataBinding expressions evaluated ? is it just before or
after the pre-render event, or somewhere else. ?
So some pointers to a well written paper would be great or a self
explaination would be really good as well.

Q4.) When the page is rendered for response to the browser, does anyone have
a pointer to a paper which outlines in which order the HTML is built.

Many Thanks.
Nov 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
1) Some of your controls will use ViewState. There is no reason to rebind
them, so you only rebind those controls that need to be rebound. If this
scenario does not fit your app, then Page.DataBind() is fine.

2) DataBinder.Eval should only be used when you need to parse from type to
type. The Eval() method will help figure out the proper means of casting. If
you are already typed, this is not a necessary step and adds weight that is
not needed. In your case, Container.DataItem is more prudent.

With the last two items, the following may help, although I am not sure they
are deep enough:

http://aspalliance.com/articleViewer.aspx?aId=134
http://www.codeproject.com/aspnet/EventsWebPage.asp

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
"Mr Newbie" wrote:
Ive got the basic idea behind DataBinding Expressions, but I have a couple
of questions, Ok its four actually :)

Q1.) It would appear that if you use Page.DataBind that all child controls
and the page get bound to their respective DataSources, is this correct ?
and if so why would you need to individually bind controls, why not jsut use
Page.DataBind everytime?, Im sure there is a good reason why not but I cant
think of one at the moment.

Q2.) The phase Container.DataItem seems to be able to appear either on its
own or within the DataBinder.Eval static function. I cant seem to find a
cohesive paper on the net that really explains well the Container.DataItem,
and where and how it should be used.

So far I have been able to bind stuff like a class level variable called
page title and have that display in a reapeater header template and also
bind things like arrays to the repeater and this works fine. But as the
array does not have a propertyname using DataBinder.Eval does not work, you
need to use Container.DataItem

Q3.) When are the DataBinding expressions evaluated ? is it just before or
after the pre-render event, or somewhere else. ?
So some pointers to a well written paper would be great or a self
explaination would be really good as well.

Q4.) When the page is rendered for response to the browser, does anyone have
a pointer to a paper which outlines in which order the HTML is built.

Many Thanks.

Nov 19 '05 #2

P: n/a
Thanks for your answers Greg,

The articles you pointed through on first glance look worth a good read so I
will do that. I like to get down to the nitty gritty and really understand
things as much as I can as I allways feel it gives one a more complete and
thorough understanding. The problem with this sort of thing is that the
information one needs to do that is often dispersed all over the world.
Regards Mr Newbie

"Cowboy (Gregory A. Beamer) - MVP" <No************@comcast.netNoSpamM> wrote
in message news:A4**********************************@microsof t.com...
1) Some of your controls will use ViewState. There is no reason to rebind
them, so you only rebind those controls that need to be rebound. If this
scenario does not fit your app, then Page.DataBind() is fine.

2) DataBinder.Eval should only be used when you need to parse from type to
type. The Eval() method will help figure out the proper means of casting.
If
you are already typed, this is not a necessary step and adds weight that
is
not needed. In your case, Container.DataItem is more prudent.

With the last two items, the following may help, although I am not sure
they
are deep enough:

http://aspalliance.com/articleViewer.aspx?aId=134
http://www.codeproject.com/aspnet/EventsWebPage.asp

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
"Mr Newbie" wrote:
Ive got the basic idea behind DataBinding Expressions, but I have a
couple
of questions, Ok its four actually :)

Q1.) It would appear that if you use Page.DataBind that all child
controls
and the page get bound to their respective DataSources, is this correct ?
and if so why would you need to individually bind controls, why not jsut
use
Page.DataBind everytime?, Im sure there is a good reason why not but I
cant
think of one at the moment.

Q2.) The phase Container.DataItem seems to be able to appear either on
its
own or within the DataBinder.Eval static function. I cant seem to find a
cohesive paper on the net that really explains well the
Container.DataItem,
and where and how it should be used.

So far I have been able to bind stuff like a class level variable called
page title and have that display in a reapeater header template and also
bind things like arrays to the repeater and this works fine. But as the
array does not have a propertyname using DataBinder.Eval does not work,
you
need to use Container.DataItem

Q3.) When are the DataBinding expressions evaluated ? is it just before
or
after the pre-render event, or somewhere else. ?
So some pointers to a well written paper would be great or a self
explaination would be really good as well.

Q4.) When the page is rendered for response to the browser, does anyone
have
a pointer to a paper which outlines in which order the HTML is built.

Many Thanks.

Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.