![]() |
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) |
Re: Data Binding - using inline code vs. functions vs. straight binding
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" <jfritts@learn.colostate.edu> wrote in message news:OixWoJA8DHA.2432@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) > > > > |
Re: Data Binding - using inline code vs. functions vs. straight binding
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:uPXChlA8DHA.2308@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" <jfritts@learn.colostate.edu> wrote in message > news:OixWoJA8DHA.2432@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) > > > > > > > > > > |
| All times are GMT. The time now is 11:06 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.