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. Advertisements

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:
    630
    Kathy Burke
    Jul 3, 2003
  2. Shapper
    Replies:
    1
    Views:
    463
    =?Utf-8?B?RWx0b24gVw==?=
    Apr 23, 2005
  3. Replies:
    4
    Views:
    815
    Chris Uppal
    May 5, 2005
  4. KK
    Replies:
    2
    Views:
    1,056
    Big Brian
    Oct 14, 2003
  5. MuZZy
    Replies:
    7
    Views:
    2,089
    Mike Hewson
    Jan 7, 2005
  6. GregStevensTX
    Replies:
    0
    Views:
    458
    GregStevensTX
    Mar 24, 2007
  7. Henrik
    Replies:
    1
    Views:
    648
    Ken Cox [Microsoft MVP]
    Jul 6, 2006
  8. domchik
    Replies:
    0
    Views:
    249
    domchik
    Sep 2, 2003
Loading...