Retrieving Cell Number

N

Newbie

Hi,
Is there a way to retrieve the cell location clicked in a datagrid? For
example, if I want to make all of the cells, clickable, to determine which
exact cell (not row) was clicked.

On click link something like:
<a href="www.newpage.com?e.item.cells(?)">

Thanks in Advance
 
E

Eliyahu Goldin

On client side you can use javascript keyword "this". Or you can use
window.event.srcElement.

Eliyahu
 
N

Newbie

Thanks, Eliyahu, and please forgive me, as I don't know javascript; however,
if I'm interpreting you, correctly (based on a google search), these
solutions would return the text of the cell. I'm trying to find out the
actual cell (location) number, so I can feed it to another page, and build
new database SQL selection criteria in VB.NET based on both the row and
column selected.
 
E

Eliyahu Goldin

Both "this" and window.event.srcElement return a reference to the element
that caused the onclick event. In your case it is a cell. It has property
cellIndex that returns the position of the cell in the row. So,
this.cellIndex is the cell number.

In the server-side code use ItemDataBound to setup client-side onclick event
handlers for the cells. Use Attribute["onclick"]="cellClicked(this);";
On the client side provide a javascript function:
function onClicked(cell){
window.navigate("www.newpage.com?"+cell.cellIndex);
}

Eliyahu
 

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,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top