Loop a list (contain multiple list)

Discussion in 'ASP .Net' started by author, Jul 27, 2004.

  1. author

    author Guest

    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
    %>
     
    author, Jul 27, 2004
    #1
    1. Advertising

  2. author

    author Guest

    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


    On Tue, 27 Jul 2004 12:02:41 GMT, author <> wrote:
    > 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
    > %>
     
    author, Jul 28, 2004
    #2
    1. Advertising

  3. author

    Ross Jones Guest

    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.


    "author" <> wrote in message
    news:...
    > 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
    >
    >
    > On Tue, 27 Jul 2004 12:02:41 GMT, author <> wrote:
    > > 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
    > > %>

    >
     
    Ross Jones, Jul 28, 2004
    #3
  4. author

    author Guest

    > 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
     
    author, Jul 28, 2004
    #4
  5. author

    Ross Jones Guest

    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.

    "author" <> wrote in message
    news:...
    > > 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
    >
     
    Ross Jones, Jul 28, 2004
    #5
  6. author

    author Guest

    > (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>
     
    author, Jul 28, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ehui928
    Replies:
    2
    Views:
    465
    ehui928
    May 29, 2006
  2. Roedy Green
    Replies:
    3
    Views:
    437
    Mike Schilling
    Sep 13, 2008
  3. Roger Pack
    Replies:
    3
    Views:
    160
    Roger Pack
    Sep 28, 2010
  4. Jason Carlton
    Replies:
    11
    Views:
    248
    Dr J R Stockton
    Dec 8, 2009
  5. Isaac Won
    Replies:
    9
    Views:
    387
    Ulrich Eckhardt
    Mar 4, 2013
Loading...

Share This Page