473,385 Members | 1,720 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,385 software developers and data experts.

Why <% %> instead of events ?

Hey
Why in all books authors are using <% DataBinder.Eval(...) %> instead of
events of datagrid for example ? There is such event like Item_DataBound but
MOST books forget about this... I believe using event will give us a full
code behind instead of ... code-behind with binding inside. Can anyone tell
me why most programmers ( including myself ) is using <% %> instead of
events. And why it's so well hidden that we can use Item_DataBound ( many
books forget to tell us there is even such a event , and usually NO EXAMPLE
on using it ). Perfomance reasons ? Code is cleaner ? Events usually needs a
few more lines... but it makes code cleaner so it's probably worth it ?
Jarod
Nov 19 '05 #1
3 1052
"Jarod" <Ja***@discussions.microsoft.com> wrote in message
news:12**********************************@microsof t.com...
Hey
Why in all books authors are using <% DataBinder.Eval(...) %> instead of
events of datagrid for example ? There is such event like Item_DataBound
but
MOST books forget about this... I believe using event will give us a full
code behind instead of ... code-behind with binding inside. Can anyone
tell
me why most programmers ( including myself ) is using <% %> instead of
events. And why it's so well hidden that we can use Item_DataBound ( many
books forget to tell us there is even such a event , and usually NO
EXAMPLE
on using it ). Perfomance reasons ? Code is cleaner ? Events usually needs
a
few more lines... but it makes code cleaner so it's probably worth it ?
Jarod


There are many different ways to build up a control tree and render it in
asp.net. I would say it's just a case of using whatever works best in a
particular circumstance. In my asp.net application we use both the
approaches you describe.

on one hand, the code is cleaner if you put it in the code behind file (I
try to steer clear of using any programming constructs in <%# %>). on the
other hand, the aspx file is supposed to contain the presentation.
Nov 19 '05 #2
> on one hand, the code is cleaner if you put it in the code behind file (I
try to steer clear of using any programming constructs in <%# %>). on the
other hand, the aspx file is supposed to contain the presentation.


Let's assume we don't anything about design... we are just programmers we
have to build an application. We put our controls on the page, and now we can
give this aspx file to the designer or after we end up programming. So
designer won't damage your job, by deleting some databinding stuff. And what
I forgot to tell DEBUGGING ! There is nothing to debug in aspx because the
debugger help is very poor ( if any ? ), but in event you can debug almost
every aspect of databinding.
Jarod
Nov 19 '05 #3
Both approaches are useful.

Normally, <%# %> can be used to handle simple situation, and ItemDataBound
event can be use to deal with complicated situation such as re-process data,
conditional showing data, and so on.

HTH

Elton Wang
el********@hotmail.com
"Jarod" wrote:
Hey
Why in all books authors are using <% DataBinder.Eval(...) %> instead of
events of datagrid for example ? There is such event like Item_DataBound but
MOST books forget about this... I believe using event will give us a full
code behind instead of ... code-behind with binding inside. Can anyone tell
me why most programmers ( including myself ) is using <% %> instead of
events. And why it's so well hidden that we can use Item_DataBound ( many
books forget to tell us there is even such a event , and usually NO EXAMPLE
on using it ). Perfomance reasons ? Code is cleaner ? Events usually needs a
few more lines... but it makes code cleaner so it's probably worth it ?
Jarod

Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Francesco Moi | last post by:
Hello. I'm trying to build a RSS feed for my website. It starts: ----------------//--------------------- <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE rss PUBLIC "-//Netscape...
1
by: Christian Schmidbauer | last post by:
Hello! I prepare my XML document like this way: ------------------------------------------------------- PrintWriter writer; Document domDocument; Element domElement; // Root tag
4
by: higabe | last post by:
Three questions 1) I have a string function that works perfectly but according to W3C.org web site is syntactically flawed because it contains the characters </ in sequence. So how am I...
129
by: Torbjørn Pettersen | last post by:
I've started cleaning up my HTML and implementing CSS. So far I've used FrontPage, but am switching over to DreamWeaver. Reading a bit on W3Schools.com and W3.org I see there are a lot of HTML...
4
by: Matt | last post by:
Hi, Got an unordered list with 100% width, with 5 list items of 20% width styled to fill the width of the container element. Renders fine in Mozilla, but when you change the size of the window...
11
by: Les Paul | last post by:
I'm trying to design an HTML page that can edit itself. In essence, it's just like a Wiki page, but my own very simple version. It's a page full of plain old HTML content, and then at the bottom,...
1
by: Ranjith Venkatesh | last post by:
I read and write to a config file which is the data store for this Windows Application written in C# using VS.NET 2003 in Windows XP. Now I want to trigger the program to read the config whenever...
4
by: David Lozzi | last post by:
Howdy, I'm using a WYSIWYG editor called TinyMCE. When I edit some text and then save it back to my SQL server using a SQLCommand, all HTML characters are changed to HTML code, i.e. &gt;strong&lt;...
4
by: Anastasios Hatzis | last post by:
I'm looking for a pattern where different client implementations can use the same commands of some fictive tool ("foo") by accessing some kind of API. Actually I have the need for such pattern for...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.