Binding an Array from a Web Service

T

Trey Bean

I'm new to ASP.NET, but have been asked to create an ASP.NET app that
retrieves data from a third-party web service.

I've managed to connect and retrieve the data from the web service, but
am having trouble getting the returned data displayed on the resulting
web page. Well, at least how I want it displayed.

Currently, in the code-behind I have the a response object that has a
method 'actions' which is an array of type 'Action'.

In the main file, I am currently using a DataList like:

<asp:DataList id="actions" runat="server" >
<ItemTemplate>
<%# Eval("actionType") %>
<%# Eval("summary") %>
</ItemTemplate>
</asp:DataList>

And I bind to this in the code-behind with:

actions.DataSource = response.actions;
actions.DataBind();

This results in each action displayed in a table cell. I would prefer
each row to be comprised of two cells, like:
<tr>
<td>actionType</td>
<td>summary</td>
</tr>

How should I go about this? Is DataList even what I need to be using?

Thanks,
Trey
 
M

Marina Levit [MVP]

Your item template may have HTML markup. So you can put a table tag in there
and create a mini table for every row.

You can also look into the Repeater control. It is like a DataList, however,
unlike the DataList it does not build a bunch of HTML around each row and
the entire list for you. It literally generates the HTML in your header,
your footer, and your item template without any of its own markup. This
gives you very fine control over what ends up being generated if that is
what you need.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,092
Latest member
vinaykumarnevatia1

Latest Threads

Top