472,141 Members | 1,466 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Unexplained error when databinding

I am using a DataSet as the DataSource of a DataList in my code. The SQL
used to get the data from the database begins with:
SELECT
members.organization,artists.artist,artists.email, artists.website,members.email
FROM members INNER JOIN artists ON members.memberid=artists.memberid WHERE
Notice that both tables involved in the SELECT statement have a field named
email. First, I do not know how to specify which one I want in my
databinding expressions (I tried DataItem.artists.email and
DataItem.members.email, but that gave me an error too). Second, I know that
my DataSet is getting filled correctly because my first databinding
expression worked (see line 71 in the error). My error is as follows:
Server Error in '/' Application.
--------------------------------------------------------------------------------

DataBinder.Eval: 'System.Data.DataRowView' does not contain a property with
the name email.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Web.HttpException: DataBinder.Eval:
'System.Data.DataRowView' does not contain a property with the name email.

Source Error:

Line 70: <ItemTemplate>
Line 71: <asp:Label id=lblOrganization1 runat="server" Width="175px"
text='<%# DataBinder.Eval(Container, "DataItem.organization")
%>'></asp:Label>
Line 72: <asp:HyperLink id="lnkPresenterEmail1" runat="server"
Width="175px" text='<%# DataBinder.Eval(Container, "DataItem.email") %>'
NavigateUrl='<%# DataBinder.Eval(Container, "DataItem.email","MAILTO:{0}")
%>' Target="_blank"></asp:HyperLink>
Line 73: <asp:Label id=lblArtist1 runat="server" Width="125" text='<%#
DataBinder.Eval(Container, "DataItem.artist") %>'></asp:Label>
Line 74: <asp:HyperLink id=lnkEmail1 runat="server" Width="175"
text='<%# DataBinder.Eval(Container, "DataItem.email") %>' NavigateUrl='<%#
DataBinder.Eval(Container, "DataItem.email","MAILTO:{0}") %>'
Target="_blank"></asp:HyperLink>

Source File: D:\Clients\12654\papresenters.org\papresenters.org \search.aspx
Line: 72

Stack Trace:

[HttpException (0x80004005): DataBinder.Eval: 'System.Data.DataRowView' does
not contain a property with the name email.]
System.Web.UI.DataBinder.GetPropertyValue(Object container, String
propName) +146
System.Web.UI.DataBinder.Eval(Object container, String[] expressionParts)
+71
System.Web.UI.DataBinder.Eval(Object container, String expression) +82
ASP.search_aspx.__DataBind__control34(Object sender, EventArgs e) in
D:\Clients\12654\papresenters.org\papresenters.org \search.aspx:72
System.Web.UI.Control.OnDataBinding(EventArgs e) +66
System.Web.UI.Control.DataBind() +26
System.Web.UI.Control.DataBind() +86
System.Web.UI.WebControls.DataList.CreateItem(Int3 2 itemIndex,
ListItemType itemType, Boolean dataBind, Object dataItem) +127
System.Web.UI.WebControls.DataList.CreateControlHi erarchy(Boolean
useDataSource) +683
System.Web.UI.WebControls.BaseDataList.OnDataBindi ng(EventArgs e) +48
System.Web.UI.WebControls.BaseDataList.DataBind() +23
PAPresenters.search.btnSearch_Click(Object sender, EventArgs e)
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1292

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2300; ASP.NET
Version:1.1.4322.2300

Can anyone help me with this? Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/
Nov 19 '05 #1
6 2204
ng
The reason you aren't finding 'email' is because SQL databases assign an
arbitrary column name if you have two matching names, or they leave the
qualifier in the name, such as artists.email and members.email. Try
assigning new names to the columns in your SQL statement, like "select
members.email m_email, artists.email a_email" and then use the new
column names in your binding.

Tom
Nathan Sokalski wrote:
I am using a DataSet as the DataSource of a DataList in my code. The SQL
used to get the data from the database begins with:
SELECT
members.organization,artists.artist,artists.email ,artists.website,members.email
FROM members INNER JOIN artists ON members.memberid=artists.memberid WHERE
Notice that both tables involved in the SELECT statement have a field named
email. First, I do not know how to specify which one I want in my
databinding expressions (I tried DataItem.artists.email and
DataItem.members.email, but that gave me an error too). Second, I know that
my DataSet is getting filled correctly because my first databinding
expression worked (see line 71 in the error). My error is as follows:
Server Error in '/' Application.
--------------------------------------------------------------------------------

DataBinder.Eval: 'System.Data.DataRowView' does not contain a property with
the name email.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Web.HttpException: DataBinder.Eval:
'System.Data.DataRowView' does not contain a property with the name email.

Source Error:

Line 70: <ItemTemplate>
Line 71: <asp:Label id=lblOrganization1 runat="server" Width="175px"
text='<%# DataBinder.Eval(Container, "DataItem.organization")
%>'></asp:Label>
Line 72: <asp:HyperLink id="lnkPresenterEmail1" runat="server"
Width="175px" text='<%# DataBinder.Eval(Container, "DataItem.email") %>'
NavigateUrl='<%# DataBinder.Eval(Container, "DataItem.email","MAILTO:{0}")
%>' Target="_blank"></asp:HyperLink>
Line 73: <asp:Label id=lblArtist1 runat="server" Width="125" text='<%#
DataBinder.Eval(Container, "DataItem.artist") %>'></asp:Label>
Line 74: <asp:HyperLink id=lnkEmail1 runat="server" Width="175"
text='<%# DataBinder.Eval(Container, "DataItem.email") %>' NavigateUrl='<%#
DataBinder.Eval(Container, "DataItem.email","MAILTO:{0}") %>'
Target="_blank"></asp:HyperLink>

Source File: D:\Clients\12654\papresenters.org\papresenters.org \search.aspx
Line: 72

Stack Trace:

[HttpException (0x80004005): DataBinder.Eval: 'System.Data.DataRowView' does
not contain a property with the name email.]
System.Web.UI.DataBinder.GetPropertyValue(Object container, String
propName) +146
System.Web.UI.DataBinder.Eval(Object container, String[] expressionParts)
+71
System.Web.UI.DataBinder.Eval(Object container, String expression) +82
ASP.search_aspx.__DataBind__control34(Object sender, EventArgs e) in
D:\Clients\12654\papresenters.org\papresenters.or g\search.aspx:72
System.Web.UI.Control.OnDataBinding(EventArgs e) +66
System.Web.UI.Control.DataBind() +26
System.Web.UI.Control.DataBind() +86
System.Web.UI.WebControls.DataList.CreateItem(Int3 2 itemIndex,
ListItemType itemType, Boolean dataBind, Object dataItem) +127
System.Web.UI.WebControls.DataList.CreateControlHi erarchy(Boolean
useDataSource) +683
System.Web.UI.WebControls.BaseDataList.OnDataBindi ng(EventArgs e) +48
System.Web.UI.WebControls.BaseDataList.DataBind() +23
PAPresenters.search.btnSearch_Click(Object sender, EventArgs e)
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1292

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2300; ASP.NET
Version:1.1.4322.2300

Can anyone help me with this? Thanks.

Nov 19 '05 #2
Bob
Nathan:

Or you could just rename the fields in the database to MEmail and AEmail

Bob
Nov 19 '05 #3
Bob
Nathan:

Or you could rename the fields in the database tables to MEmail and AEmail.

Dont forget to clean up the garbage code left behind in the "Windows Form
Designer Generated Code.

Seems to be a problem with VS not doing it when you regenerate the DA's

Today I cleaned up some 2000 lines of code in there. Big diff in
performance.

Bob

"Nathan Sokalski" <nj********@hotmail.com> wrote in message
news:O7*************@TK2MSFTNGP10.phx.gbl...
I am using a DataSet as the DataSource of a DataList in my code. The SQL
used to get the data from the database begins with:
SELECT
members.organization,artists.artist,artists.email, artists.website,members.email
FROM members INNER JOIN artists ON members.memberid=artists.memberid WHERE
Notice that both tables involved in the SELECT statement have a field
named email. First, I do not know how to specify which one I want in my
databinding expressions (I tried DataItem.artists.email and
DataItem.members.email, but that gave me an error too). Second, I know
that my DataSet is getting filled correctly because my first databinding
expression worked (see line 71 in the error). My error is as follows:
Server Error in '/' Application.
--------------------------------------------------------------------------------

DataBinder.Eval: 'System.Data.DataRowView' does not contain a property
with the name email.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Web.HttpException: DataBinder.Eval:
'System.Data.DataRowView' does not contain a property with the name email.

Source Error:

Line 70: <ItemTemplate>
Line 71: <asp:Label id=lblOrganization1 runat="server" Width="175px"
text='<%# DataBinder.Eval(Container, "DataItem.organization")
%>'></asp:Label>
Line 72: <asp:HyperLink id="lnkPresenterEmail1" runat="server"
Width="175px" text='<%# DataBinder.Eval(Container, "DataItem.email") %>'
NavigateUrl='<%# DataBinder.Eval(Container, "DataItem.email","MAILTO:{0}")
%>' Target="_blank"></asp:HyperLink>
Line 73: <asp:Label id=lblArtist1 runat="server" Width="125" text='<%#
DataBinder.Eval(Container, "DataItem.artist") %>'></asp:Label>
Line 74: <asp:HyperLink id=lnkEmail1 runat="server" Width="175" text='<%#
DataBinder.Eval(Container, "DataItem.email") %>' NavigateUrl='<%#
DataBinder.Eval(Container, "DataItem.email","MAILTO:{0}") %>'
Target="_blank"></asp:HyperLink>

Source File:
D:\Clients\12654\papresenters.org\papresenters.org \search.aspx Line: 72

Stack Trace:

[HttpException (0x80004005): DataBinder.Eval: 'System.Data.DataRowView'
does not contain a property with the name email.]
System.Web.UI.DataBinder.GetPropertyValue(Object container, String
propName) +146
System.Web.UI.DataBinder.Eval(Object container, String[]
expressionParts) +71
System.Web.UI.DataBinder.Eval(Object container, String expression) +82
ASP.search_aspx.__DataBind__control34(Object sender, EventArgs e) in
D:\Clients\12654\papresenters.org\papresenters.org \search.aspx:72
System.Web.UI.Control.OnDataBinding(EventArgs e) +66
System.Web.UI.Control.DataBind() +26
System.Web.UI.Control.DataBind() +86
System.Web.UI.WebControls.DataList.CreateItem(Int3 2 itemIndex,
ListItemType itemType, Boolean dataBind, Object dataItem) +127
System.Web.UI.WebControls.DataList.CreateControlHi erarchy(Boolean
useDataSource) +683
System.Web.UI.WebControls.BaseDataList.OnDataBindi ng(EventArgs e) +48
System.Web.UI.WebControls.BaseDataList.DataBind() +23
PAPresenters.search.btnSearch_Click(Object sender, EventArgs e)
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108

System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1292

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2300;
ASP.NET Version:1.1.4322.2300

Can anyone help me with this? Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

Nov 19 '05 #4
>
Or you could just rename the fields in the database to MEmail and AEmail

That is something I never would do. The method of ng is in my opinion the
right one.

Just my thought,

Cor
Nov 19 '05 #5
Bob
Cor:

Why not? Wouldn't it make things a little easyer to inerpret and provide
for less aliases?

Bob
Nov 19 '05 #6
Nathan:

Change this:

SELECT
members.organization,artists.artist,artists.email, artists.website,member
s.email
FROM members INNER JOIN artists ON members.memberid=artists.memberid

to this:

SELECT m.organization, a.artist, a.email As AEmail,
a.website, m.email As MEmail
FROM members m
INNER JOIN artists a
ON m.memberid = a.memberid

This is called aliasing the tables and the columns that have the same
name (notice that I put an "m" after members and an "a" after artists;
these are the aliases for the tables). Your datatable (in the dataset)
will use the aliased named (Aemail and Memail). This way you can leave
your database as is.

John

Nov 19 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Michael Kennedy [UB] | last post: by
6 posts views Thread by Thomas Connolly | last post: by
1 post views Thread by Matt | last post: by
1 post views Thread by Nathan Sokalski | last post: by
5 posts views Thread by Nathan Sokalski | last post: by
reply views Thread by leo001 | last post: by

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.