Get current cell in datagrid

G

Guest

Hi,

I have a dynamically built datagrid. I have a checkbox and a label in each
cell. When the checkbox is ticked something should happen, using the label in
the same cell as the checkbox. But I do not know which column it will be
ticked in. Obviously I can get the checkbox using sender, and I can get the
datagrid item using what I've done below. but my third line is where I am
stuck. Can anyone help?

CheckBox cb = (CheckBox)sender;
DataGridItem dgItem = (DataGridItem)(cb.NamingContainer);
intSomeID = ((Label)dgItem.cell i am within.Controls[1]).Text
 
G

Guest

Hello Louise,

Use the reference to checkbox control to loop through the containing
controls collection of the DataGridItem to find the location of the checkbox.


In implementing nested controls within databound template controls you can
make the implementation easier by using event delegates and customized event
handlers to pass the exact information that you need. The client that would
use your control would get all the information that you want to communicate
to them through the event arguments. I have an example that demonstrates to
you how to create the event delegates and the event handlers on this link:
http://www.societopia.net/Samples/DataGridEventDelegates.aspx

HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
 

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,994
Messages
2,570,222
Members
46,809
Latest member
moe77

Latest Threads

Top