Comparing a Datagrid items to a datareader results - Help Please

Discussion in 'ASP .Net Datagrid Control' started by Jamie Sutherland, Apr 13, 2004.

  1. 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()
    Jamie Sutherland, Apr 13, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. KathyB
    Replies:
    8
    Views:
    464
    Kathy Burke
    Jul 3, 2003
  2. Shapper
    Replies:
    1
    Views:
    362
    =?Utf-8?B?RWx0b24gVw==?=
    Apr 23, 2005
  3. KK
    Replies:
    2
    Views:
    497
    Big Brian
    Oct 14, 2003
  4. GregStevensTX
    Replies:
    0
    Views:
    375
    GregStevensTX
    Mar 24, 2007
  5. Henrik
    Replies:
    1
    Views:
    407
    Ken Cox [Microsoft MVP]
    Jul 6, 2006
Loading...

Share This Page