Loop a list (contain multiple list)

  • Thread starter Thread starter author
  • Start date Start date
A

author

How can I do the below classic ASP in .NET ??

- I have tried using a repeater, but can only get one long list, in my
ex. I need a list (contains 3 list)

TIA

---

Some data for the recordset...
--
groupID, item
1, item 1
1, item 2
1, item 3
2, item 4
2, item 5
3, item 6
--


<%
groupID = -1

do while not RS.EOF
if groupID <> RS("groupID") then
groupID = RS("groupID")
Response.Write(groupID)
end if

Response.Write(RS("item"))

RS.movenext
loop
%>
 
Where is all the .Net experts in this group ??

It can't be that complicated, pretty simple code. I really need some
help for the source-code below.

TIA
 
Hi,

You might need to be a bit more explicit in your request.

1. Which .Net language do you want help porting it to?
2. Do you need help connecting to the database or just working with the
results?


Ross.
 
1. Which .Net language do you want help porting it to?

I dev. in VB.. but any language is fine.

2. Do you need help connecting to the database or just working with the
results?

Just need help working with the results.


TIA
 
Well assuming that you have a DataTable containing your results (which you
may have filled from a SqlDataAdapter)
in C# (the VB.Net will be slightly different) the code might look like
(assuming I have not misunderstood your question).

DataTable table = .....

int groupId = -1;
foreach( DataRow row in table.Rows )
{
if ( (int)row["groupID"] != groupId )
{
groupId = (int)row["groupID"];
Response.Write( groupId );
}
Response.Write( (string)row["item"] );
}

HTH,

Ross.
 
(assuming I have not misunderstood your question).

I don't know ;)

- but I will try to explain what I need, with some code (I know don't
work). I hope you understand the logic with this ??


<asp:Repeater Id="groupList" RunAt="server">
<ItemTemplate>

<%
if Container.DataItem("groupID") <> groupID then
groupID = Container.DataItem("groupID")
%>
<tr>
<td colspan="2"><%# if Container.DataItem("groupID")%></td>
</tr>
<% end if %>

<tr>
<td><%# Container.DataItem("itemID")%></td>
<td><%# Container.DataItem("itemText")%></td>
</tr>

</ItemTemplate>
</asp:Repeater>
 
Back
Top