views:

62

answers:

3

I am stuck in converting this snipped to asp.net.

set RSLinksCat = conn.Execute("select linkscat.id, linkscat.category from linkscat, contentlinks, links where contentlinks.linksid = links.id and contentlinks.contentid = " & contentid & " and links.linkscatid = linkscat.id order by linkscat.category")


<%if not RSLinksCat.EOF then%><h1>Links</h1>
<br />
<%do while not RSLinksCat.EOF%>
<%set RSLinks = conn.Execute("select * from links where linkscatid = " & RSLinksCat("id") & "")%>

 <strong><%=RSlinkscat("category")%><strong>
    <ul>
                    <%do while not RSlinks.EOF%>
                    <li>
                      <a href = "http://&lt;%=RSLinks("url")%&gt;" target="_blank"><%=RSlinks("description")%></a>
                    </li>
                     <%RSLinks.MoveNext
                    loop%>
    </ul>
                 <%RSLinksCat.MoveNext
                 loop%>
<br />
<%end if%><%conn.close%>

I'm not sure where to start. Can anyone recommend the correct approach i.e sqldatareaders or repeaters or arrays or sqldatareaders or? VB code samples most welcome.

Thanks

+1  A: 

Please look at the DataList, Repeater, or similar Server Control samples to see how to implement what you need.

TheGeekYouNeed
+1  A: 

Phil

Start from give some small time and find a Dal Data access layer, a communication way with your database, like subsonic 2.3, or linq to sql.

Then if you see any example on this DALs and play few days with it, the rest will be very easy.

Also you need to move from asp to asp.net thinking that asp.net is something different, and not because both have the asp, means something. I mean that you do not just port the code from one to the other... needs more to get out the thesaurus of asp.net.

Aristos
+2  A: 

If you came from the ASP Classic world, you may find ASP.net MVC easy to deal with. No need to learn what server control do you need or how to deal with the ViewState.

Converted code, using LINQ as DAL:

<h1>Links</h1>
<br />
<% For each linkcat in Model%>
<strong><%=linkcat.category%><strong>
  <ul>
     <% For each link in linkcat.Links%>
        <li>
        <a href="http://&lt;%=Link.url%&gt;" target="_blank"><%=links.description%></a>
        </li>
    <% Next %>
    </ul>
<br />
<% Next %>
Eduardo Molteni