Checkbox in Datagrid

Hi,

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,
xianxian

Comments

  • Hi,
    i finally had it working :-


    Protected Sub RowChanged(ByVal sender As System.Object, ByVal e As
    System.EventArgs)
    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
    a.Add(rec)
    Else
    Dim chkSel As CheckBox = CType(dgItem.Cells(0).Controls(1),
    CheckBox)
    If chkSel.Checked = False Then
    a.Remove(rec)
    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 "http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchTopQuestionsAboutASPNETDataGridServerControl.asp"
    titled "Checking for Changed items" in the section "Editing Multiple Rows At Once"
Sign In or Register to comment.

Howdy, Stranger!

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

Categories

In this Discussion