DataList Binding

Tamer_Ahmed

Centurion
Joined
Dec 20, 2003
Messages
159
Location
Egypt
hi all i'm trying to bing datareader to datalist and here's my code
Dim cn As New SqlConnection("data source = localhost;initial catalog = northwind;integrated security = sspi;")
Dim cm As New SqlCommand("select firstname,lastname from employees", cn)
Dim dr As SqlDataReader
cn.Open()
dr = cm.ExecuteReader
DataList1.DataSource = dr
DataList1.DataBind()
dr.Close()
cn.Close()
well i create table and put it in the iteam template of the datalist
<asp:DataList id="DataList1" style="Z-INDEX: 102; LEFT: 16px; POSITION: absolute; TOP: 48px" runat="server" RepeatColumns="3" Height="258px" Width="304px" RepeatDirection="Horizontal">
<ItemTemplate>
<TABLE id="Table1" style="Z-INDEX: 101; LEFT: 8px; WIDTH: 296px; POSITION: absolute; TOP: 8px; HEIGHT: 64px" cellSpacing="1" cellPadding="1" width="296" border="1">
<TR>
<TD style="WIDTH: 101px"><STRONG>First Name :</STRONG></TD>
<TD>
<%# DataBinder.Eval(Container.DataItem, "FirstName") %>
</TD>
</TR>
<TR>
<TD style="WIDTH: 101px"><STRONG>Last Name :</STRONG></TD>
<TD>
<%# DataBinder.Eval(Container.DataItem, "LastName") %>
</tr>
</Table>
</ItemTemplate>
the problem here that i want to show in every row 3 column and every column contain this table and this is not what happening here it put all the table in the same place hope anyone can help
 
Hi,

Can you clarify that you want to have three columns from your datasource per row in the datalist and also clarify what your current code is doing.

When you do this I will see if I can help you as I have also been diong a lot of work with DataReaders and DataLists.

Thanks

Ash
 
Back
Top