ASP.NET, DataList, and WebService Question

Discussion in 'ASP .Net' started by Roger R. Smith, Jan 22, 2004.

  1. Anyway I am having a problem with Web Service and DataList in ASP.NET. so
    the best way to explain it would be with the MSPetShop 3.0 Application.
    I submitted an order using the Forms on http://localhost/MSPetShop. then I
    created my own ASp.NET Project and I have a form on which I have a DataList,
    b/c I want to display a bunch of items. BUt for this example I did the
    following:

    localhost.WebServices webservices = new localhost.WebServices();
    localhost.OrderInfo order = webservices.GetOrder(1);
    IList orderList = new ArrayList();
    orderList.Add(order);
    DataList1.DataSource = orderList;
    DataList1.DataBind();
    I added the Order to an ArrayList just to test, and then on the codebehind I
    have the following:
    <asp:DataList id="DataList1" style="Z-INDEX: 104; LEFT: 136px; POSITION:
    absolute; TOP: 248px"
    runat="server">
    <HEADERTEMPLATE>
    Roger
    </HEADERTEMPLATE>
    <ItemTemplate>
    <TD><%# DataBinder.Eval(Container.DataItem, "OrderId") %></TD>
    </ItemTemplate>
    </asp:DataList>

    but with this I am getting the following error:
    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:
    'WebServicePortal.localhost.OrderInfo' does not contain a property with the
    name OrderId.

    Source Error:


    Line 45: </HEADERTEMPLATE>
    Line 46: <ItemTemplate>
    Line 47: <TD><%# DataBinder.Eval(Container.DataItem, "OrderId") %></TD>
    Line 48: </ItemTemplate>
    Line 49: </asp:DataList></P>


    This is the same error I am getting on my application.
    Any ideas?
     
    Roger R. Smith, Jan 22, 2004
    #1
    1. Advertising

  2. Hi Roger,

    I don't think you need to use the DataBinder.Eval. Just display the
    dataitem since there can be only one:

    <asp:DataList id="DataList1" runat="server">
    <HEADERTEMPLATE>
    Roger
    </HEADERTEMPLATE>
    <ItemTemplate>
    <TD><%# Container.DataItem %></TD>
    </ItemTemplate>
    </asp:DataList>

    Ken
    MVP [ASP.NET]

    "Roger R. Smith" <> wrote in message
    news:...
    > Anyway I am having a problem with Web Service and DataList in ASP.NET. so
    > the best way to explain it would be with the MSPetShop 3.0 Application.
    > I submitted an order using the Forms on http://localhost/MSPetShop. then I
    > created my own ASp.NET Project and I have a form on which I have a
    > DataList,
    > b/c I want to display a bunch of items. BUt for this example I did the
    > following:
    >
    > localhost.WebServices webservices = new localhost.WebServices();
    > localhost.OrderInfo order = webservices.GetOrder(1);
    > IList orderList = new ArrayList();
    > orderList.Add(order);
    > DataList1.DataSource = orderList;
    > DataList1.DataBind();
    > I added the Order to an ArrayList just to test, and then on the codebehind
    > I
    > have the following:
    > <asp:DataList id="DataList1" style="Z-INDEX: 104; LEFT: 136px; POSITION:
    > absolute; TOP: 248px"
    > runat="server">
    > <HEADERTEMPLATE>
    > Roger
    > </HEADERTEMPLATE>
    > <ItemTemplate>
    > <TD><%# DataBinder.Eval(Container.DataItem, "OrderId") %></TD>
    > </ItemTemplate>
    > </asp:DataList>
    >
    > but with this I am getting the following error:
    > 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:
    > 'WebServicePortal.localhost.OrderInfo' does not contain a property with
    > the
    > name OrderId.
    >
    > Source Error:
    >
    >
    > Line 45: </HEADERTEMPLATE>
    > Line 46: <ItemTemplate>
    > Line 47: <TD><%# DataBinder.Eval(Container.DataItem, "OrderId") %></TD>
    > Line 48: </ItemTemplate>
    > Line 49: </asp:DataList></P>
    >
    >
    > This is the same error I am getting on my application.
    > Any ideas?
    >
    >
     
    Ken Cox [Microsoft MVP], Jan 23, 2004
    #2
    1. Advertising

  3. Roger R. Smith

    Roger Smith Guest

    HI Ken, thanks so much for your help.
    The only problem is, that was an example so for my real one, I do have
    multiple properties to display.
    Any ideas?
    Thanks
    Rog



    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Roger Smith, Jan 23, 2004
    #3
  4. Hi Roger,

    Perhaps you could post a sample of the data that you are getting so we could
    analyze what need to be caught?

    "Roger Smith" <> wrote in message
    news:%...
    > HI Ken, thanks so much for your help.
    > The only problem is, that was an example so for my real one, I do have
    > multiple properties to display.
    > Any ideas?
    > Thanks
    > Rog
    >
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
     
    Ken Cox [Microsoft MVP], Jan 23, 2004
    #4
  5. Thanks Ken,
    Well I tried the same basic thing but with DataGrid and I get the following:

    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.NullReferenceException: Object reference not set
    to an instance of an object.

    Source Error:

    Line 27: localhost.OrderInfo order = service.GetOrder(1);
    Line 28: orderList.Add(order);
    Line 29: DataGrid1.DataSource = orderList;
    Line 30: DataGrid1.DataBind();
    Line 31: }


    "Ken Cox [Microsoft MVP]" <> wrote in message
    news:...
    > Hi Roger,
    >
    > Perhaps you could post a sample of the data that you are getting so we

    could
    > analyze what need to be caught?
    >
    > "Roger Smith" <> wrote in message
    > news:%...
    > > HI Ken, thanks so much for your help.
    > > The only problem is, that was an example so for my real one, I do have
    > > multiple properties to display.
    > > Any ideas?
    > > Thanks
    > > Rog
    > >
    > >
    > >
    > > *** Sent via Developersdex http://www.developersdex.com ***
    > > Don't just participate in USENET...get rewarded for it!

    >
     
    Roger R. Smith, Jan 23, 2004
    #5
    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. Gönen EREN

    Datalist in Datalist How?

    Gönen EREN, Aug 22, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    425
    Gönen EREN
    Aug 22, 2003
  2. Nevyn Twyll
    Replies:
    8
    Views:
    1,972
  3. Andrea Raimondi
    Replies:
    1
    Views:
    552
  4. Mr. x
    Replies:
    2
    Views:
    742
    Andrew
    Oct 10, 2003
  5. Roger R. Smith

    ASP.NET, DataList, and WebService

    Roger R. Smith, Jan 22, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    251
    Roger R. Smith
    Jan 22, 2004
Loading...

Share This Page