Data Binding - using inline code vs. functions vs. straight binding

Discussion in 'ASP .Net' started by Jordan, Feb 10, 2004.

  1. Jordan

    Jordan Guest

    I'm curious if the whole point of Repeaters/Data Lists/Grids is
    encapsulating additional functionality like add/update/edit/deletes, but
    really does not provide any benefits when it comes to simply displaying
    information.

    For example, if I wanted ONLY to show information (not edit/adds/etc) in a
    format that is similar, but has customized text (ex. make this word a link
    if the quantity is > 0). Which of these methods would be better, if anyonc
    of them can be considered "better":

    1) Straight Loops w/o Using a Control
    While (Dr.Read()) {
    ...
    if (Dr.GetInt32[3] > 0) { ...}
    ...
    }

    2) Using a Repeater w/o Functions to Customize Look
    <repeater >
    <itemtemplate>
    <table><tr><td>...</td></tr>
    <%# ShowQuantityLink(Databinder.Eval(Container.DataItem,
    "Quanitity")) %>
    </table>
    </itemtemplate>
    </repeater>

    3) or simply removing the function call, and putting all the function code
    in the same place.

    4) Also, I could use the OnItemTemplateCreated method of the Repeater object
    as well...

    Because all the code will be compiled before executing, does it really
    matter how I choose to simply display information? (granted, selecting a
    certain method provides OO benefits which I'm not getting into here)
     
    Jordan, Feb 10, 2004
    #1
    1. Advertising

  2. Actually it's not always compiled beforehand. If you have any code in <% %>
    tags, it doesn't get compiled until runtime by the JIT compiler. If
    performance is what you are after, your first method will be the fastest. I
    read an article once (which I can't find now), which compared these controls
    to the "do it yourself" methods. Bottom line was, these controls are going
    to take a little longer to spit the data out than if you had done it
    manually. In my opinion, it's worth the wait.


    "Jordan" <> wrote in message
    news:...
    > I'm curious if the whole point of Repeaters/Data Lists/Grids is
    > encapsulating additional functionality like add/update/edit/deletes, but
    > really does not provide any benefits when it comes to simply displaying
    > information.
    >
    > For example, if I wanted ONLY to show information (not edit/adds/etc) in a
    > format that is similar, but has customized text (ex. make this word a link
    > if the quantity is > 0). Which of these methods would be better, if anyonc
    > of them can be considered "better":
    >
    > 1) Straight Loops w/o Using a Control
    > While (Dr.Read()) {
    > ...
    > if (Dr.GetInt32[3] > 0) { ...}
    > ...
    > }
    >
    > 2) Using a Repeater w/o Functions to Customize Look
    > <repeater >
    > <itemtemplate>
    > <table><tr><td>...</td></tr>
    > <%# ShowQuantityLink(Databinder.Eval(Container.DataItem,
    > "Quanitity")) %>
    > </table>
    > </itemtemplate>
    > </repeater>
    >
    > 3) or simply removing the function call, and putting all the function

    code
    > in the same place.
    >
    > 4) Also, I could use the OnItemTemplateCreated method of the Repeater

    object
    > as well...
    >
    > Because all the code will be compiled before executing, does it really
    > matter how I choose to simply display information? (granted, selecting a
    > certain method provides OO benefits which I'm not getting into here)
    >
    >
    >
    >
     
    Michael Ramey, Feb 10, 2004
    #2
    1. Advertising

  3. Jordan

    Jordan Guest

    Right about the compilation. I guess I said that becuase you can't use <% %>
    in a "runat=server" control, which was used in my examples, but you can use
    <% %> in my manually looping....aaannnyway, you answered my question (and
    I couldn't find any articles that came right out and said it, hence my
    post).

    Thanks, Jordan


    "Michael Ramey" <raterus@localhost> wrote in message
    news:...
    > Actually it's not always compiled beforehand. If you have any code in <%

    %>
    > tags, it doesn't get compiled until runtime by the JIT compiler. If
    > performance is what you are after, your first method will be the fastest.

    I
    > read an article once (which I can't find now), which compared these

    controls
    > to the "do it yourself" methods. Bottom line was, these controls are

    going
    > to take a little longer to spit the data out than if you had done it
    > manually. In my opinion, it's worth the wait.
    >
    >
    > "Jordan" <> wrote in message
    > news:...
    > > I'm curious if the whole point of Repeaters/Data Lists/Grids is
    > > encapsulating additional functionality like add/update/edit/deletes, but
    > > really does not provide any benefits when it comes to simply displaying
    > > information.
    > >
    > > For example, if I wanted ONLY to show information (not edit/adds/etc) in

    a
    > > format that is similar, but has customized text (ex. make this word a

    link
    > > if the quantity is > 0). Which of these methods would be better, if

    anyonc
    > > of them can be considered "better":
    > >
    > > 1) Straight Loops w/o Using a Control
    > > While (Dr.Read()) {
    > > ...
    > > if (Dr.GetInt32[3] > 0) { ...}
    > > ...
    > > }
    > >
    > > 2) Using a Repeater w/o Functions to Customize Look
    > > <repeater >
    > > <itemtemplate>
    > > <table><tr><td>...</td></tr>
    > > <%# ShowQuantityLink(Databinder.Eval(Container.DataItem,
    > > "Quanitity")) %>
    > > </table>
    > > </itemtemplate>
    > > </repeater>
    > >
    > > 3) or simply removing the function call, and putting all the function

    > code
    > > in the same place.
    > >
    > > 4) Also, I could use the OnItemTemplateCreated method of the Repeater

    > object
    > > as well...
    > >
    > > Because all the code will be compiled before executing, does it really
    > > matter how I choose to simply display information? (granted, selecting

    a
    > > certain method provides OO benefits which I'm not getting into here)
    > >
    > >
    > >
    > >

    >
    >
     
    Jordan, Feb 10, 2004
    #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. Replies:
    3
    Views:
    490
  2. Daniel Vallstrom
    Replies:
    2
    Views:
    2,040
    Kevin Bracey
    Nov 21, 2003
  3. Osiris
    Replies:
    11
    Views:
    686
    Roman Yakovenko
    Dec 31, 2006
  4. Rahul
    Replies:
    3
    Views:
    479
    James Kanze
    Feb 28, 2008
  5. Rishi Boparai

    How to go straight to snippet code list

    Rishi Boparai, May 5, 2008, in forum: ASP .Net
    Replies:
    0
    Views:
    293
    Rishi Boparai
    May 5, 2008
Loading...

Share This Page