Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / July 2005

Tip: Looking for answers? Try searching our database.

System.Data.Common.DbDataRecord

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
dotnettester - 20 Jul 2005 14:41 GMT
I have a DataGrid with a checkbox as ItemTemplate....

<asp:DataGrid id="Datagrid3" runat="server" AutoGenerateColumns="False" >
<Columns>
   <asp:TemplateColumn>
     <ItemTemplate>
       <asp:CheckBox id="Chk"  Text="<%# Container.DataItem %>"  
runat="server">
        </asp:CheckBox>
     </ItemTemplate>
   </asp:TemplateColumn>
</Columns>
</asp:DataGrid>

in my codebehind file I have a query
Select productname form product, the results of which are held in a DataReader
and the DataReader is the source of Data for Datagrid3.

Query exectues fine but on the page I get the following instead of the
actual data.
System.Data.Common.DbDataRecord.

What am I doing wrong?

Thanx in advance.
Jacek Stawicki - 20 Jul 2005 14:51 GMT
Text property of CheckBox control really doesn't matter.

Of course, you can write:

<asp:CheckBox id="Chk"  Text='<%# DataBinder.Eval(Container.DataItem, "Tax")
%>' runat="server"/>

but you also can use this syntax:

<asp:CheckBox id="Chk" runat="server"/><%#
DataBinder.Eval(Container.DataItem, "Tax") %>

Signature

C# Dev

> I have a DataGrid with a checkbox as ItemTemplate....
>
[quoted text clipped - 21 lines]
>
> Thanx in advance.
Eliyahu Goldin - 20 Jul 2005 15:02 GMT
Text="<%# ((System.Data.Common.DbDataRecord)Container.DataItem)["productname
"] %>"

or

Text="<%# ((System.Data.Common.DbDataRecord)Container.DataItem)[0] %>"

Eliyahu

> I have a DataGrid with a checkbox as ItemTemplate....
>
[quoted text clipped - 21 lines]
>
> Thanx in advance.
Karl Seguin - 20 Jul 2005 15:22 GMT
I'd generally recommend the late-bound DataBinder.Eval method rather then
the early-bound casting.  I think the minor performance penalty paid is well
worth it for the clean layer seperation.   Why should your presentation
layer be aware of the underlying data source?  Early-binding in this case
means you can't change simply change your business layer without affecting
everything else...

Karl

Signature

MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)

> Text="<%#
> ((System.Data.Common.DbDataRecord)Container.DataItem)["productname
[quoted text clipped - 32 lines]
>>
>> Thanx in advance.
Eliyahu Goldin - 20 Jul 2005 15:35 GMT
Karl,

I saw your opinion on this in your other posts. The MSDN on the Eval method
warns:

CAUTION   Since this method performs late-bound evaluation, using
reflection, at runtime, it can cause performance to noticeably slow compared
to standard ASP.NET data-binding syntax.

Are you aware of any performance tests proving that the performance penalty
is minor rather then noticeable?

Eliyahu

> I'd generally recommend the late-bound DataBinder.Eval method rather then
> the early-bound casting.  I think the minor performance penalty paid is well
[quoted text clipped - 42 lines]
> >>
> >> Thanx in advance.
Karl Seguin - 20 Jul 2005 16:03 GMT
I'm largely basing it on my own observation of both methods (I've used both
back and forth, and am currently (obviously) in the n-tier wins side).
I've read in a number of blogs and blog comments that it's a hit anywhere
from 10-20%.  Assuming that's true, it's highly situational, based on how
large the data set is.   I guess my warning should be worded better:

Be aware that using DataBinder.Eval has a performance penalty proportional
to the way you are using (width (columns) and size (rows) of the data).
However, it provides greater layer seperation and makes your code easier to
maintain and less brittle.  You should pick the best method for your given
scenerio.  Personally, I tend to value maintainability far more than
performance and will use the more maintainable approach first, profile, and
only adjust for performance when deemed necessary.

I like to make sure people understand both sides of a coin and make the best
choice for their situation....I think you and I do a decent job on that on
here :)

Cheers,
Karl

Signature

MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)

> Karl,
>
[quoted text clipped - 62 lines]
>> >>
>> >> Thanx in advance.
Eliyahu Goldin - 20 Jul 2005 16:21 GMT
Looks like your warning is written by a professional lawyer :)

Eliyahu

> I'm largely basing it on my own observation of both methods (I've used both
> back and forth, and am currently (obviously) in the n-tier wins side).
[quoted text clipped - 83 lines]
> >> >>
> >> >> Thanx in advance.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.