DataSet Iteration?

A

Adam

Hi All,

What is the most acceptable way of iterating through a DataSet Tables Row
Collections Manually?
As in:

'fill data adapter object with dataset info
Da = New SqlDataAdapter(Cmd)
Da.Fill(Ds)

'iterate through Area Grouops
Do While() ????

'create new drop down list item
lstItem = New ListItem()
lstItem.Text = " -" & rdrAssessmentAreas("name")
lstItem.Value = rdrAssessmentAreas("assmnt_area_id")

'add new list item to drop down list
ddlAssessmentAreas.Items.Add(lstItem)

Loop

Cheers,
Adam
 
S

Steve C. Orr [MVP, MCSD]

I'd suggest something along these lines:

For Each row As DataRow in MyDataSet.Tables(0)
lstItem.Text = row("name").ToString()
Next
 
S

Steve C. Orr [MVP, MCSD]

I'd suggest something along these lines:

For Each row As DataRow in MyDataSet.Tables(0).Rows
lstItem.Text = row("name").ToString()
Next
 
A

Adam

Beautiful!

Thanks.

Steve C. Orr said:
I'd suggest something along these lines:

For Each row As DataRow in MyDataSet.Tables(0).Rows
lstItem.Text = row("name").ToString()
Next
 

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

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top