Select a row for highlighting - Gridview control with checkbox

I have a checkbox column in my gridview control. I want to make it so on checkchanged it selects the row or deselects the row so the row is highlighted. Here is the code I have so far. I just need to select the row now.

    Protected Sub CheckBox1_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs)
        Dim CB As CheckBox
        CB = CType(sender, CheckBox)

        If CB.Checked = True Then
            'select the row so its highlighted
        ElseIf CB.Checked = False Then
            'unselect the row so its no longer highlighted
        End If
    End Sub
bertino12Asked:
Who is Participating?
 
chinu1310Commented:
Hi,

Couple of solutions here.
http://forums.asp.net/p/1079698/1594091.aspx

Hope it helps.
0
 
NeotkCommented:
Protected Sub CheckBox1_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs)
        Dim CB As CheckBox
        CB = CType(sender, CheckBox)

        If CB.Checked = True Then
            //I'm doing a cast on CheckBox parent to GridViewRow and then setting its color, do this in VB
            ((GridViewRow)CB.parent).BackColor = System.Drawing.Color.Red; //C# code, you must fit to VB
        ElseIf CB.Checked = False Then
           //I'm doing a cast on CheckBox parent to GridViewRow and then setting its color, do this in VB
           ((GridViewRow)CB.parent).BackColor = System.Drawing.Color.White; //C# code, you must fit to VB
        End If
    End Sub

Regards, Rodrigo Leote
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.