Reputation: 1437
I want to create DataList control and I want to have 2 columns first for "First Name" second for "Last Name". Like this:
First Name|Second Name
Peter   Johnson
John   Peterson
When I try with this code, isn't working. This isn't arrange the names as I want:
<asp:DataList ID="NamesDataList" runat="server" >
<HeaderTemplate>
First Name
Last Name
</HeaderTemplate>
<ItemTemplate>
<%# Eval("FirstName")%>
<%# Eval("LastName")%>
</ItemTemplate>
</asp:DataList>
I want to have DataList control like this one for example. https://www.packtpub.com/sites/default/files/Article-Images/asp.net-img03.png
Upvotes: 0
Views: 435
Reputation: 2562
Try this
<asp:DataList ID="NamesDataList" runat="server" >
<HeaderTemplate>
<table>
<tr>
<td>First Name</td>
<td>Last Name</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table>
<tr>
<td><asp:Label ID="lblRaterName" runat="server" Text='<%# Eval("FirstName")%>'></asp:Label> </td>
<td><asp:Label ID="lblRaterName" runat="server" Text='<%# Eval("LastName")%>'></asp:Label></td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
Upvotes: 1