473,406 Members | 2,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Parent Control!

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[????]);

}
Jan 15 '06 #1
2 1419
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

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Adam J Knight" wrote:
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[????]);

}

Jan 15 '06 #2
Adam for you reference try this page to translate
http://www.developerfusion.co.uk/uti...btocsharp.aspx
Hope that helps
Patrick

"Adam J Knight" <ad**********@optusnet.com.au> wrote in message
news:eH*************@tk2msftngp13.phx.gbl...
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[????]);

}

Jan 16 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
by: Steve Jorgensen | last post by:
Yup, Steve's full of tips, but hey, it makes him feel important, right? Ok, here goes. I've been trying to improve encapsulation by putting code in the same object as the stuff it affects, so I...
3
by: David N | last post by:
Hi All, I just wonder if in C#, I can develop a user defined control that can call its parent function which is not yet developed. For example, how do I make my user control call a...
5
by: Zürcher See | last post by:
The Control class has the Parent property that is readonly. When the control is added to a controls collection of another control the Parent property refers to that control. "Who" set the Parent...
1
by: Earl Teigrob | last post by:
I did a ton of searching to try and find a simple solution to this issue and finally wrote my own, which I am sharing with everyone. In my searching, I did find a very complete and robust solution at...
1
by: Danny Ni | last post by:
Hi, I have a web form A that contains an user control B, which contains an user control C. Inside user control C, can I call methods in user control B and web form A? If yes, How? The mthods...
5
by: Steve Richter | last post by:
In my user control I want to read the ViewState dictionary of the Parent control. But this sensible idea is not permitted by the compiler: Compiler Error Message: CS1540: Cannot access...
4
by: TS | last post by:
When i try to access the page class or parent properties inside a server control that is nested in another server control, they are null. I don't even call CreateChildControls for the parent...
12
by: Tom W | last post by:
What's the difference in these three?
5
by: gnewsgroup | last post by:
In my user control, I would like to find a Label control in the parent page (the page that uses my user control). I need to update that Label.Text when something happens in the user control. I...
4
by: Andrew | last post by:
I want to create a set of Activity Diagram controls for process control. I need to create a base Diagram control that acts as a container for the Activity controls ( StartPoint, EndPoint,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.