473,386 Members | 2,078 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

ASP.NET, DataList, and WebService Question

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?
Nov 18 '05 #1
4 3500
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" <ro****@yahoo.com> wrote in message
news:Ol**************@tk2msftngp13.phx.gbl...
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?


Nov 18 '05 #2
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!
Nov 18 '05 #3
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" <ro****@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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!


Nov 18 '05 #4
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]" <BA************@sympatico.ca> wrote in message
news:Ok**************@tk2msftngp13.phx.gbl...
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" <ro****@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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!

Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Rob Manger | last post by:
Hi All, This may be a stupid question, and may not be the correct solution for my problem, but here goes. I want to include a datalist within a datalist, in order to effectively group items...
0
by: ani | last post by:
I have few questions regarding datalist control. 1) How do I retrieve the values that are present in the datalist control. My aspx page actually reloads to itself, and the datalist control has...
1
by: Glenn Owens | last post by:
Here's the scenario: I have a DataList populated from a datatable sitting inside a fieldset. Each element (row) in the Datalist has the following child controls: asp:checkbox, asp:image,...
4
by: tshad | last post by:
I have a DataList that I have set up to allow editing. The edit button does go to the subroutine defined by OnEditCommand. The problem is that it doesn't change the fields to editing fields. The...
0
by: Patrick Olurotimi Ige | last post by:
I have a Datalist and i want CheckBoxes in it. The Datalist is popluated from the Database. I want to be able to select the checkboxes with the populated Datalist and insert to table. But i want...
4
by: Patrick.O.Ige | last post by:
I have a CheckBoxList in a DataList and i'm trying to get item Selected after doing a postBack. I have set my CheckBoxlist AutoPostBack="True" Any ideas what 'm doing wrong? It seems not to...
2
by: Hans Merkl | last post by:
Hi, I am trying to use a user control as EditItemTemplate in a DataList. It loads fine but I can't figure out how to bind to the data of the DataList. Here is what I have got so far: ...
1
by: AJ | last post by:
Hi all, With the following code in mind : <asp:DataList ID="dlOne" DataKeyField="myField1" DataSource="<%# GetDataSource1()" Runat="server"> <ItemTemplate> Output Value Here! <asp:DataList...
3
by: rn5a | last post by:
I want to change the background color of a row in a DataList when the mouse is moved over a row. This is how I tried but it doesn't change the background color of a row in the DataList when the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.