System.Data.Common.DbDataRecord

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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") %>
 
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

--
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!)
Eliyahu Goldin said:
Text="<%#
((System.Data.Common.DbDataRecord)Container.DataItem)["productname
"] %>"

or

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

Eliyahu

dotnettester said:
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.
 
Text="<%# ((System.Data.Common.DbDataRecord)Container.DataItem)["productname
"] %>"

or

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

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).
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

--
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!)
Eliyahu Goldin said:
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

Karl Seguin said:
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

--
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!)
Eliyahu Goldin said:
Text="<%#
((System.Data.Common.DbDataRecord)Container.DataItem)["productname
"] %>"

or

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

Eliyahu

message
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.
 
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

Karl Seguin said:
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

--
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!)
Eliyahu Goldin said:
Text="<%#
((System.Data.Common.DbDataRecord)Container.DataItem)["productname
"] %>"

or

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

Eliyahu

dotnettester said:
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.
 
Looks like your warning is written by a professional lawyer :)

Eliyahu

Karl Seguin said:
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

--
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!)
Eliyahu Goldin said:
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

Karl Seguin said:
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

--
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
"] %>"

or

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

Eliyahu

message
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.
 
Back
Top