Parent Control!

  • Thread starter Thread starter Adam J Knight
  • Start date Start date
A

Adam J Knight

Hi all,

Below i have a function which is executed when a check boxes 'CHECKED'
property is changed.
This checkbox is contain within a datagrid item in a datagrid.

What i am after is how to retrieve the datagrid item in which the checkbox
resides.

I have done this in a previous project using visual basic...

eg: dgEmps.DataKeys(CType(sender.Parent.Parent, DataGridItem).ItemIndex)

What i need is the c# equivalent:

Any help appreciated!!!

public void chkEnrolled_Changed(object sender, System.EventArgs e)
{

Response.Write(dgEnrollments.DataKeys[????]);

}
 
Adam,
The "C#" equivalent would be:

dgEmps.DataKeys[((DataGridItem)sender.Parent.Parent).ItemIndex];

As can be seen, the syntax knowledge needed is not particularly difficult.
Good practice to be able to translate between VB.NET and C#.
Peter
 
Back
Top