Databinding Expressions & Page Rendering Sequence

Discussion in 'ASP .Net' started by Mr Newbie, Sep 19, 2005.

  1. Mr Newbie

    Mr Newbie Guest

    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.
     
    Mr Newbie, Sep 19, 2005
    #1
    1. Advertising

  2. 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.
    >
    >
    >
     
    =?Utf-8?B?Q293Ym95IChHcmVnb3J5IEEuIEJlYW1lcikgLSBN, Sep 19, 2005
    #2
    1. Advertising

  3. Mr Newbie

    Mr Newbie Guest

    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" <> wrote
    in message news:...
    > 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.
    >>
    >>
    >>
     
    Mr Newbie, Sep 19, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter Mount
    Replies:
    4
    Views:
    1,002
    Peter Mount
    Jan 31, 2006
  2. jobs
    Replies:
    0
    Views:
    1,765
  3. stef mientki
    Replies:
    13
    Views:
    690
    stef mientki
    Oct 20, 2007
  4. Savvoulidis Iordanis

    Page event sequence and Databinding question

    Savvoulidis Iordanis, Sep 24, 2008, in forum: ASP .Net
    Replies:
    2
    Views:
    374
    Savvoulidis Iordanis
    Sep 25, 2008
  5. Earl Teigrob
    Replies:
    1
    Views:
    444
    Shravan
    Mar 1, 2004
Loading...

Share This Page