Link to home
Start Free TrialLog in
Avatar of glennkerr
glennkerr

asked on

Which checkbox was checked in a web DataGrid?

I have a webpage that shows a company's aircraft (what types of Aircraft they have).
I have a datalist, that displays Aircraft Categories.
Inside that, is a datagrid, that displays a checkbox, and an Aircraft Type on each row.
It's all nicely bound, and shows the checkbox checked/not checked when appropriate.

I'd like to respond to the checkbox's OnCheckedChanged event to either add or delete a row in the underlying table as the user checks or unchecks the checkbox.

Here's the sub...
    Public Sub chkType_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles chkType.CheckedChanged

    End Sub

But how do I know which row in the datagrid was checked/unchecked?
Avatar of glennkerr
glennkerr

ASKER

Here's the answer...

    Public Sub chkType_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles chkType.CheckedChanged
        'sender.parent is cell, and it's parent is the DataGridItem
        Dim dgi As System.Web.UI.WebControls.DataGridItem = CType(sender.parent.parent, System.Web.UI.WebControls.DataGridItem)
        Dim lblTypeID As System.Web.UI.WebControls.Label = CType(dgi.FindControl("lblTypeID"), System.Web.UI.WebControls.Label)
    End Sub

Moderator: Request refund, as I answered my own question.
(unless anybody else has anything good to add?)
ASKER CERTIFIED SOLUTION
Avatar of EE_AutoDeleter
EE_AutoDeleter

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial