Checkbox in Datagrid - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Checkbox in Datagrid

xianxianxianxian Posts: 5Member

i have a column in my Datagrid that contains Checkboxes..
i need the user to select the Checkbox then store the id value of that row, into an ArrayList. i have done that & it works.

The problem is, when user deselects a Checkbox, how do i remove the id of that row from the ArrayList?

thanks in advance,


  • xianxianxianxian Posts: 5Member
    i finally had it working :-

    Protected Sub RowChanged(ByVal sender As System.Object, ByVal e As
    Dim a As New ArrayList
    If Not Session("SelectResults") Is Nothing Then
    a = CType(Session("SelectResults"), ArrayList)
    End If

    Dim dgItem As DataGridItem = CType(CType(sender,
    Control).NamingContainer, DataGridItem)
    Dim rec As Integer = CInt(dgItem.Cells(9).Text)

    If Not a.Contains(rec) Then
    Dim chkSel As CheckBox = CType(dgItem.Cells(0).Controls(1),
    If chkSel.Checked = False Then
    End If
    End If

    Session("SelectResults") = a
    End Sub

    *PS: "rec" is a record number, just a unique item for every Checkbox in
    my Datagrid.
    Note that I have to first check whether the item is in my Arraylist,
    before i check for Checked=False. If i do it the other way round, it
    would not work.

    in HTML, just add OnCheckedChanged="RowChanged" :-


    This is just my own example, the reference is at ""
    titled "Checking for Changed items" in the section "Editing Multiple Rows At Once"
Sign In or Register to comment.