Comparing a Datagrid items to a datareader results - Help Please

J

Jamie Sutherland

Hi,
I have a datagrid which has 3 coloumns adn about 10 rows. The Coloumns have
the following fields one is a (chkPrimary) checkbox field and another is
a(lblAccountID) Label field and the other is (lblAccountName) Label field.
I need to have these cheboxes ticked if the lblAccountID value is in another
table. Below is the code so far but does not work. any help please...
Thanks
Jamie

Dim dgItems As DataGridItem
Dim chkselected As CheckBox
Dim cmdGroups As New SqlCommand("SELECT AccountType_ID, Username,
PrimaryGroup from Group_memberShip Where" & _
" username = '" & userID & "' and (PrimaryGroup =1)", conn)
conn.Open()
dr = cmdGroups.ExecuteReader

Do While dr.Read
For Each dgItems In dgGroups.Items
chkselected = CType(dgItems.FindControl("chkPrimary"), CheckBox)

If dr("AccountType_ID") Is CType(dgItems.FindControl("lblAccountID"), Label)
Then
chkselected.Checked = True
End If

Next
Loop

dr.Close()
conn.Close()
 

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,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top