Loop a list (contain multiple list)

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
%>
 
A

author

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
 
R

Ross Jones

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.
 
A

author

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
 
R

Ross Jones

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.
 
A

author

(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>
 

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,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top