473,327 Members | 2,081 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,327 software developers and data experts.

Get current cell in datagrid

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
Nov 19 '05 #1
1 1621
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/Da...Delegates.aspx

HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"louise raisbeck" wrote:
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

Nov 19 '05 #2

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

Similar topics

4
by: Terry | last post by:
Hey, Having somewhat of an issue, I have a datagrid which is giving me issues. The Datagrid is setup for the user to double click the row, the row is selected and data within that row populates a...
1
by: VM | last post by:
Is it possible for the bound data in a web datagrid to be displayed in links? The grid will show the client's first name and last name and, when the user clicks on the first or last name, I want...
0
by: elime | last post by:
Hi all I have a strange behaving on some PC with my DataGrid. It only occurs on some PC, on others it works perfectly fine. ->(same ..net version installed) it's very confusing. starting...
0
by: Tony Fields | last post by:
Please Help!!! I need to capture the following for the current cell of a datagrid on a webpage when I double-click a cell: 1. Field name (ie. "State", which should be the same as the label,...
2
by: DraguVaso | last post by:
Hi, I'm looking for a nice way to format the cell of my datagrid according to some predefined 'rules'. I found a lot on the site of George shepherd, but it wasn't really what I was looking for:...
21
by: coleenholley | last post by:
I've been trying since last Friday to get an answer on how to get a SPECIFIC row.cell value from a datagrid. I've had plenty of suggestions, but nothing works to get the value from a SPECIFIC Row...
10
by: JohnR | last post by:
I have a datatable as the datasource to a datagrid. The datagrid has a datagridtablestyle defined. I use the datagridtablestyle to change the order of the columns (so they can be different than...
2
by: benfly08 | last post by:
Hi, everyone. I got a weird problem for my C# program. In my program, I use a DataGrid to display data. I bind the DataGrid to a DataTable. I made all the cells in DataGrid ReadOnly as True. So...
1
by: Aaaaash | last post by:
how can we know which cell has been selected or clicked in DataGrid. I need to know the current Row And Column of the cell.
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.