Unexplained error when databinding

Discussion in 'ASP .Net Web Controls' started by Nathan Sokalski, Aug 25, 2005.

  1. 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(Int32 itemIndex,
    ListItemType itemType, Boolean dataBind, Object dataItem) +127
    System.Web.UI.WebControls.DataList.CreateControlHierarchy(Boolean
    useDataSource) +683
    System.Web.UI.WebControls.BaseDataList.OnDataBinding(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.IPostBackEventHandler.RaisePostBackEvent(String
    eventArgument) +57
    System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
    sourceControl, String eventArgument) +18
    System.Web.UI.Page.RaisePostBackEvent(NameValueCollection 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

    http://www.nathansokalski.com/
     
    Nathan Sokalski, Aug 25, 2005
    #1
    1. Advertising

  2. Nathan Sokalski

    ng Guest

    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.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(Int32 itemIndex,
    >ListItemType itemType, Boolean dataBind, Object dataItem) +127
    > System.Web.UI.WebControls.DataList.CreateControlHierarchy(Boolean
    >useDataSource) +683
    > System.Web.UI.WebControls.BaseDataList.OnDataBinding(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.IPostBackEventHandler.RaisePostBackEvent(String
    >eventArgument) +57
    > System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
    >sourceControl, String eventArgument) +18
    > System.Web.UI.Page.RaisePostBackEvent(NameValueCollection 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.
    >
    >
     
    ng, Aug 25, 2005
    #2
    1. Advertising

  3. Nathan Sokalski

    Bob Guest

    Nathan:

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

    Bob
     
    Bob, Aug 26, 2005
    #3
  4. Nathan Sokalski

    Bob Guest

    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" <> wrote in message
    news:...
    >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(Int32 itemIndex,
    > ListItemType itemType, Boolean dataBind, Object dataItem) +127
    > System.Web.UI.WebControls.DataList.CreateControlHierarchy(Boolean
    > useDataSource) +683
    > System.Web.UI.WebControls.BaseDataList.OnDataBinding(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.IPostBackEventHandler.RaisePostBackEvent(String
    > eventArgument) +57
    > System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
    > sourceControl, String eventArgument) +18
    > System.Web.UI.Page.RaisePostBackEvent(NameValueCollection 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
    >
    > http://www.nathansokalski.com/
    >
     
    Bob, Aug 26, 2005
    #4
  5. >
    > 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
     
    Cor Ligthert [MVP], Aug 26, 2005
    #5
  6. Nathan Sokalski

    Bob Guest

    Cor:

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

    Bob
     
    Bob, Aug 26, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Michiel

    NEWBIE:unexplained syntax error

    Michiel, Sep 9, 2004, in forum: Perl
    Replies:
    2
    Views:
    514
    Barry Kimelman
    Sep 10, 2004
  2. Marty Cruise

    Unexplained Instance Error

    Marty Cruise, Jul 3, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    410
    David Waz..
    Jul 3, 2003
  3. Nathan Sokalski

    Unexplained error when databinding

    Nathan Sokalski, Aug 25, 2005, in forum: ASP .Net
    Replies:
    6
    Views:
    2,198
    John Horst
    Aug 26, 2005
  4. =?Utf-8?B?am9uZWZlcg==?=

    Sudden unexplained IE validation error

    =?Utf-8?B?am9uZWZlcg==?=, Feb 5, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    378
    =?Utf-8?B?am9uZWZlcg==?=
    Feb 5, 2007
  5. Earl Teigrob
    Replies:
    1
    Views:
    437
    Shravan
    Mar 1, 2004
Loading...

Share This Page