Syntax to loop through the DataList

J

jmhmaine

My Code:

HTML for Panel 1
<asp:DataList ID="dlItems" Runat=server DataKeyField="Prod_PK" >
<ItemTemplate>
<table class="ItemTable" cellSpacing="0" cellPadding="1" width="400"
border="0">
<tr>
<td width="300" class="ProdName">
<%# Container.DataItem("Prod_Name") %></td>
<td width="100" class="ProdQty">Qty</td>
</tr>
<tr>
<td width="300"><%# Container.DataItem("Prod_Description") %>
Cost: $<%# Container.DataItem("Prod_Price") %></td>
<td width="100" valign="top" align="center">
<asp:TextBox id="txtProdQty" CssClass="txtProdQty" Runat=server
/></td>
</tr>
<tr>
<td colspan="2"><hr id="ProdHR" /></td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>

Question:
For Panel 2 I want to loop through the DataList, and create a DataGrid using
the DataKey and the Quantity Value and bind the DataGrid. In this case I know
how to build the DataGrid, I just need the syntax to loop through the
DataList from Panel1
 
E

Elton Wang

Use
dlItems.DataKeys(I)
to get pk
and use
CType(dlItems(I).FindControl("txtProdQty"), TextBox).Text
to get QTY

HTH
 
J

jmhmaine

Thanks. I ended up going with:
CType(dlItems.Items(I).FindControl("txtProdQty"), TextBox).Text
 

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,772
Messages
2,569,591
Members
45,103
Latest member
VinaykumarnNevatia
Top