Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data Looping Question

Status
Not open for further replies.
Jan 26, 2001
550
GB
Dear all

Please bear with me as this is a probably a pretty basic question but I'm having trouble getting my head around asp.net 2.0 after years of developing with classic asp.

I know that there are loads of automated data collection types such as the grid view and repeater controls, but what is the best way to replicate the old fashioned 'recordset' behaviour?

Basically I want to pull out a table of 'quicklinks' from the database into a data collection which I can loop through, perform some logic on each item (to decide what name/url to dispay) and then add the items to a bulleted list.

Basically this kind of pseudo-code:

Code:
   quickLinkSQL = "SELECT * FROM QLINKS WHERE DateDiff('d', QLINK_STARTDATE, #" & DateTime.Now & "#) >= 0 AND DateDiff('d', QLINK_ENDDATE, #" & DateTime.Now & "#) <= 0 AND QLINK_ACTIVE=True"
   quickLinksDataSource.SelectCommand = quickLinkSQL

   Dim quickLinksCollection As DataCollection
   For Each DataRow in quickLinksCollection
      
      Dim flURL As String
      Dim strLink As String
      
      Select Case rs3("QLINK_TYPE")
      Case "Publication Section"
	flURL = "publicationscheme.asp?pubcatid=" & rs3("QLINK_PUBCATID")
      Case "Publication"
         flURL = "publication.asp?id=" & rs3("QLINK_PUBLICATIONID")
      Case "News Item"
         fLURL = "viewnews.asp?id=" & rs3("QLINK_NEWSID")
      End Select

      strItemLink = "<a href='" & flURL & "'>" & rs3("QLINK_TITLE") & "</a>"

      MyBulletedlist.Items.Add(strItemLink)

   Next

So my question is which type of data collection, if any, can I use to perform this kind of looping with logic?
How would you approach a similar scenario?

Any help would be vastly appreciated
Many thanks

Nick (Webmaster)

 
Have a look at the DataReader and DataTable examples from here. Also, you should look into using the data bound event for whichever control is displaying the data as this can be used to modify the current row's output.


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top