A
Adam J Knight
Hi all,
I have an app, containing a datagrid. Each datagrid item contains a
checkbox.
When a given check boxes state is changed, i need to be able determine which
datagrid item
contains the updated check box.
In a previous project written in vb the code for doing this was:
dgEmps.DataKeys(CType(sender.Parent.Parent, DataGridItem).ItemIndex)))
On this forum it was suggested that the C# equivalent is:
dgEmps.DataKeys[((DataGridItem)sender.Parent.Parent).ItemIndex];
Unfortunately however, this doesn't seem to work.
I keep getting the error message...object does not contain a definition for
parent.
This error is reported in relation to the line 'sender.Parent.Parent' code.
Here is my function definition:
public void chkEnrolled_Changed(object sender, System.EventArgs e)
{
myVar =
dgEnrollments.DataKeys[((DataGridItem)sender.Parent.Parent).ItemIndex]));
}
Can anyone help me get around this issue??
Cheers,
Adam
I have an app, containing a datagrid. Each datagrid item contains a
checkbox.
When a given check boxes state is changed, i need to be able determine which
datagrid item
contains the updated check box.
In a previous project written in vb the code for doing this was:
dgEmps.DataKeys(CType(sender.Parent.Parent, DataGridItem).ItemIndex)))
On this forum it was suggested that the C# equivalent is:
dgEmps.DataKeys[((DataGridItem)sender.Parent.Parent).ItemIndex];
Unfortunately however, this doesn't seem to work.
I keep getting the error message...object does not contain a definition for
parent.
This error is reported in relation to the line 'sender.Parent.Parent' code.
Here is my function definition:
public void chkEnrolled_Changed(object sender, System.EventArgs e)
{
myVar =
dgEnrollments.DataKeys[((DataGridItem)sender.Parent.Parent).ItemIndex]));
}
Can anyone help me get around this issue??
Cheers,
Adam