Databinding Expressions & Page Rendering Sequence

M

Mr Newbie

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.
 
G

Guest

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!
***************************
 
M

Mr Newbie

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
 

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,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top