473,386 Members | 1,803 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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
2 1970
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Cees Wesseling | last post by:
For a couple of years I am using now my own data binding tool that can create C++ classes from a DTD. At this moment I need to reconsider this tool since I want to use W3C XML Schemas and need to...
9
by: Anon Email | last post by:
Hi people, I'm learning about header files in C++. The following is code from Bartosz Milewski: // Code const int maxStack = 16; class IStack
4
by: Vinay | last post by:
Hello My question is regarding "weak external symbols". Consider the following eg. class test { public : int func1(void); {cout <<"func1";} int func2(void);
4
by: Thomas Paul Diffenbach | last post by:
Can anyone point me to an open source library of /statically allocated/ data structures? I'm writing some code that would benefit from trees, preferably self balancing, but on an embedded system...
18
by: Method Man | last post by:
If I don't care about the size of my executable or compile time, is there any reason why I wouldn't want to inline every function in my code to make the program run more efficient?
19
by: Paul | last post by:
hi, there, for example, char *mystr="##this is##a examp#le"; I want to replace all the "##" in mystr with "****". How can I do this? I checked all the string functions in C, but did not...
5
by: Bert Jansen | last post by:
There seems to be a bug in de VS .net C++ compiler (optimization) when using inline functions that return static data. The following code demonstrates this (Win32 console app with ATL support): ...
12
by: JMB | last post by:
Hello, I was wondering if anyone knew of any projects extending the inline upload progress bar to utilize an inpage image uploader with bar, without having to refresh or go to a seperate page,...
2
by: subramanian100in | last post by:
Is my following understanding correct ? Data abstraction means providing the interface - that is, the set of functions that can be called by the user of a class. Information hiding means...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.