467,146 Members | 1,313 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,146 developers. It's quick & easy.

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

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.DataIte m,
"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)


Nov 18 '05 #1
  • viewed: 1840
Share:
2 Replies
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" <jf*****@learn.colostate.edu> wrote in message
news:Oi**************@TK2MSFTNGP10.phx.gbl...
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.DataIte m,
"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)

Nov 18 '05 #2
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:uP**************@TK2MSFTNGP11.phx.gbl...
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" <jf*****@learn.colostate.edu> wrote in message
news:Oi**************@TK2MSFTNGP10.phx.gbl...
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.DataIte m,
"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)


Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Cees Wesseling | last post: by
4 posts views Thread by Vinay | last post: by
4 posts views Thread by Thomas Paul Diffenbach | last post: by
18 posts views Thread by Method Man | last post: by
5 posts views Thread by Bert Jansen | last post: by
2 posts views Thread by subramanian100in@yahoo.com, India | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.