Parent Control!!!

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top