Unexplained error when databinding

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nathan Sokalski

    #1

    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.organiz ation,artists.a rtist,artists.e mail,artists.we bsite,members.e mail
    FROM members INNER JOIN artists ON members.memberi d=artists.membe rid 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.artist s.email and
    DataItem.member s.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.Da taRowView' 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.Http Exception: DataBinder.Eval :
    'System.Data.Da taRowView' does not contain a property with the name email.

    Source Error:

    Line 70: <ItemTemplate >
    Line 71: <asp:Label id=lblOrganizat ion1 runat="server" Width="175px"
    text='<%# DataBinder.Eval (Container, "DataItem.organ ization")
    %>'></asp:Label>
    Line 72: <asp:HyperLin k id="lnkPresente rEmail1" 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.artis t") %>'></asp:Label>
    Line 74: <asp:HyperLin k 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\1265 4\papresenters. org\papresenter s.org\search.as px
    Line: 72

    Stack Trace:

    [HttpException (0x80004005): DataBinder.Eval : 'System.Data.Da taRowView' does
    not contain a property with the name email.]
    System.Web.UI.D ataBinder.GetPr opertyValue(Obj ect container, String
    propName) +146
    System.Web.UI.D ataBinder.Eval( Object container, String[] expressionParts )
    +71
    System.Web.UI.D ataBinder.Eval( Object container, String expression) +82
    ASP.search_aspx .__DataBind__co ntrol34(Object sender, EventArgs e) in
    D:\Clients\1265 4\papresenters. org\papresenter s.org\search.as px:72
    System.Web.UI.C ontrol.OnDataBi nding(EventArgs e) +66
    System.Web.UI.C ontrol.DataBind () +26
    System.Web.UI.C ontrol.DataBind () +86
    System.Web.UI.W ebControls.Data List.CreateItem (Int32 itemIndex,
    ListItemType itemType, Boolean dataBind, Object dataItem) +127
    System.Web.UI.W ebControls.Data List.CreateCont rolHierarchy(Bo olean
    useDataSource) +683
    System.Web.UI.W ebControls.Base DataList.OnData Binding(EventAr gs e) +48
    System.Web.UI.W ebControls.Base DataList.DataBi nd() +23
    PAPresenters.se arch.btnSearch_ Click(Object sender, EventArgs e)
    System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +108
    System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring
    eventArgument) +57
    System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
    sourceControl, String eventArgument) +18
    System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData) +33
    System.Web.UI.P age.ProcessRequ estMain() +1292



    --------------------------------------------------------------------------------
    Version Information: Microsoft .NET Framework Version:1.1.432 2.2300; ASP.NET
    Version:1.1.432 2.2300



    Can anyone help me with this? Thanks.
    --
    Nathan Sokalski
    njsokalski@hotm ail.com
    有声小说网为广大读者提供热门小说在线免费阅读,本站收集的网络文学小说情节跌宕起伏,有声小说网是值得书友们收藏的小说在线阅读网。



  • ng

    #2
    Re: Unexplained error when databinding

    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:
    [color=blue]
    >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.organi zation,artists. artist,artists. email,artists.w ebsite,members. email
    >FROM members INNER JOIN artists ON members.memberi d=artists.membe rid 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.artist s.email and
    >DataItem.membe rs.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.Eva l: 'System.Data.Da taRowView' 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.Http Exception: DataBinder.Eval :
    >'System.Data.D ataRowView' does not contain a property with the name email.
    >
    >Source Error:
    >
    >Line 70: <ItemTemplate >
    >Line 71: <asp:Label id=lblOrganizat ion1 runat="server" Width="175px"
    >text='<%# DataBinder.Eval (Container, "DataItem.organ ization")
    >%>'></asp:Label>
    >Line 72: <asp:HyperLin k id="lnkPresente rEmail1" 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.Eva l(Container, "DataItem.artis t") %>'></asp:Label>
    >Line 74: <asp:HyperLin k id=lnkEmail1 runat="server" Width="175"
    >text='<%# DataBinder.Eval (Container, "DataItem.email ") %>' NavigateUrl='<% #
    >DataBinder.Eva l(Container, "DataItem.email ","MAILTO:{ 0}") %>'
    >Target="_blank "></asp:HyperLink>
    >
    >Source File: D:\Clients\1265 4\papresenters. org\papresenter s.org\search.as px
    >Line: 72
    >
    >Stack Trace:
    >
    >[HttpException (0x80004005): DataBinder.Eval : 'System.Data.Da taRowView' does
    >not contain a property with the name email.]
    > System.Web.UI.D ataBinder.GetPr opertyValue(Obj ect container, String
    >propName) +146
    > System.Web.UI.D ataBinder.Eval( Object container, String[] expressionParts )
    >+71
    > System.Web.UI.D ataBinder.Eval( Object container, String expression) +82
    > ASP.search_aspx .__DataBind__co ntrol34(Object sender, EventArgs e) in
    >D:\Clients\126 54\papresenters .org\papresente rs.org\search.a spx:72
    > System.Web.UI.C ontrol.OnDataBi nding(EventArgs e) +66
    > System.Web.UI.C ontrol.DataBind () +26
    > System.Web.UI.C ontrol.DataBind () +86
    > System.Web.UI.W ebControls.Data List.CreateItem (Int32 itemIndex,
    >ListItemType itemType, Boolean dataBind, Object dataItem) +127
    > System.Web.UI.W ebControls.Data List.CreateCont rolHierarchy(Bo olean
    >useDataSourc e) +683
    > System.Web.UI.W ebControls.Base DataList.OnData Binding(EventAr gs e) +48
    > System.Web.UI.W ebControls.Base DataList.DataBi nd() +23
    > PAPresenters.se arch.btnSearch_ Click(Object sender, EventArgs e)
    > System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +108
    > System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring
    >eventArgumen t) +57
    > System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
    >sourceContro l, String eventArgument) +18
    > System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData) +33
    > System.Web.UI.P age.ProcessRequ estMain() +1292
    >
    >
    >
    >--------------------------------------------------------------------------------
    >Version Information: Microsoft .NET Framework Version:1.1.432 2.2300; ASP.NET
    >Version:1.1.43 22.2300
    >
    >
    >
    >Can anyone help me with this? Thanks.
    >
    >[/color]

    Comment

    • Bob

      #3
      Re: Unexplained error when databinding

      Nathan:

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

      Bob


      Comment

      • Bob

        #4
        Re: Unexplained error when databinding

        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" <njsokalski@hot mail.com> wrote in message
        news:O7mAc3bqFH A.208@TK2MSFTNG P10.phx.gbl...[color=blue]
        >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.organiz ation,artists.a rtist,artists.e mail,artists.we bsite,members.e mail
        > FROM members INNER JOIN artists ON members.memberi d=artists.membe rid 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.artist s.email and
        > DataItem.member s.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.Da taRowView' 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.Http Exception: DataBinder.Eval :
        > 'System.Data.Da taRowView' does not contain a property with the name email.
        >
        > Source Error:
        >
        > Line 70: <ItemTemplate >
        > Line 71: <asp:Label id=lblOrganizat ion1 runat="server" Width="175px"
        > text='<%# DataBinder.Eval (Container, "DataItem.organ ization")
        > %>'></asp:Label>
        > Line 72: <asp:HyperLin k id="lnkPresente rEmail1" 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.artis t") %>'></asp:Label>
        > Line 74: <asp:HyperLin k 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\1265 4\papresenters. org\papresenter s.org\search.as px Line: 72
        >
        > Stack Trace:
        >
        > [HttpException (0x80004005): DataBinder.Eval : 'System.Data.Da taRowView'
        > does not contain a property with the name email.]
        > System.Web.UI.D ataBinder.GetPr opertyValue(Obj ect container, String
        > propName) +146
        > System.Web.UI.D ataBinder.Eval( Object container, String[]
        > expressionParts ) +71
        > System.Web.UI.D ataBinder.Eval( Object container, String expression) +82
        > ASP.search_aspx .__DataBind__co ntrol34(Object sender, EventArgs e) in
        > D:\Clients\1265 4\papresenters. org\papresenter s.org\search.as px:72
        > System.Web.UI.C ontrol.OnDataBi nding(EventArgs e) +66
        > System.Web.UI.C ontrol.DataBind () +26
        > System.Web.UI.C ontrol.DataBind () +86
        > System.Web.UI.W ebControls.Data List.CreateItem (Int32 itemIndex,
        > ListItemType itemType, Boolean dataBind, Object dataItem) +127
        > System.Web.UI.W ebControls.Data List.CreateCont rolHierarchy(Bo olean
        > useDataSource) +683
        > System.Web.UI.W ebControls.Base DataList.OnData Binding(EventAr gs e) +48
        > System.Web.UI.W ebControls.Base DataList.DataBi nd() +23
        > PAPresenters.se arch.btnSearch_ Click(Object sender, EventArgs e)
        > System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +108
        >
        > System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring
        > eventArgument) +57
        > System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
        > sourceControl, String eventArgument) +18
        > System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData) +33
        > System.Web.UI.P age.ProcessRequ estMain() +1292
        >
        >
        >
        > --------------------------------------------------------------------------------
        > Version Information: Microsoft .NET Framework Version:1.1.432 2.2300;
        > ASP.NET Version:1.1.432 2.2300
        >
        >
        >
        > Can anyone help me with this? Thanks.
        > --
        > Nathan Sokalski
        > njsokalski@hotm ail.com
        > http://www.nathansokalski.com/
        >[/color]


        Comment

        • Cor Ligthert [MVP]

          #5
          Re: Unexplained error when databinding

          >[color=blue]
          > Or you could just rename the fields in the database to MEmail and AEmail
          >[/color]
          That is something I never would do. The method of ng is in my opinion the
          right one.

          Just my thought,

          Cor


          Comment

          • Bob

            #6
            Re: Unexplained error when databinding

            Cor:

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

            Bob


            Comment

            Working...