Larry Brister
asked on
Checkbox list
I have a radList that uses checkboxes.
My attached code sets everything to checked EXCEPT the first item on the returned data. It always skips the first one.
My attached code sets everything to checked EXCEPT the first item on the returned data. It always skips the first one.
If dR.HasRows Then
Dim j As Integer
' Check only those which match with database
If dR.HasRows Then
Do While dR.Read()
For j = 0 To RadListBox1.Items.Count - 1
If RadListBox1.Items(j).Value = dR("fips") Then
RadListBox1.Items(j).Checked = True
End If
Next
Loop
End If
Else
ASKER
13598
The full sub is attached
The full sub is attached
Protected Sub selectLinks(ByVal id As Integer)
Dim objConn As SqlConnection
objConn = New SqlConnection(System.Configuration.ConfigurationManager.AppSettings("strConn"))
Dim oCom As SqlCommand
oCom = New SqlCommand
oCom.Connection = objConn
oCom.CommandText = "dbo.sp_parse_list"
oCom.CommandType = CommandType.StoredProcedure
oCom.Parameters.Add(New SqlParameter("@id", SqlDbType.Int)).Value = id
oCom.Parameters.Add(New SqlParameter("@col", SqlDbType.VarChar, 20)).Value = "fips"
oCom.Parameters.Add(New SqlParameter("@tbl", SqlDbType.VarChar, 20)).Value = "court_Runners"
objConn.Open()
Dim dR As SqlDataReader
dR = oCom.ExecuteReader()
dR.Read()
If dR.HasRows Then
Dim j As Integer
' Check only those which match with database
If dR.HasRows Then
Do While dR.Read()
For j = 0 To RadListBox1.Items.Count - 1
If RadListBox1.Items(j).Value = dR("fips") Then
RadListBox1.Items(j).Checked = True
End If
Next
Loop
End If
Else
End If
End Sub
REmove dr.Read()
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
13598:
Oh man...that is REALLY embarrassing!
As soon as I copied my code into the EE and submitted I saw it.
End of day brain gas!
Thanks
Oh man...that is REALLY embarrassing!
As soon as I copied my code into the EE and submitted I saw it.
End of day brain gas!
Thanks
It happens lol
ASKER
Thanks...end of day tired brain!
Are you reading the dr I suppose?
Then your Do while dr.read brings in the second record since you read once to find out if there are any rows. You skipped the first record.