double click on grid

M

Mike

I want to double click on a row within the grid and have it take me to a
edit screen for that row.
Currently I allow the user highlight a row and click the Edit Button and
that takes them to a edit screen,
can I have it work the same way if they double click the row?
 
E

Eliyahu Goldin

Yes. In the ItemDataBound event setup client-side event like this:

e.Item.Attributes["ondblclick"] = "onDblClick(this)";

And provide a javascript event handler:

function onDblClick(row) {
document.getElementById("inpRowId").innerText=row.cells(0).innerText;
document.getElementById("btnEdit").click();
}

Note following points:
1. The first line of the function assign row id to a <input type=hidden>
control to send the row id to the server. It is assumed that the first
column of the grid contains row id. You can make this column invisible with
stylesheet attribute display:none. Don't hide it on the server side.
2. The second line of the script simulates pressing your Edit button which
should cause a postback.

Eliyahu.
 
M

Mike

thanks i'll give this a shot
Eliyahu Goldin said:
Yes. In the ItemDataBound event setup client-side event like this:

e.Item.Attributes["ondblclick"] = "onDblClick(this)";

And provide a javascript event handler:

function onDblClick(row) {
document.getElementById("inpRowId").innerText=row.cells(0).innerText;
document.getElementById("btnEdit").click();
}

Note following points:
1. The first line of the function assign row id to a <input type=hidden>
control to send the row id to the server. It is assumed that the first
column of the grid contains row id. You can make this column invisible with
stylesheet attribute display:none. Don't hide it on the server side.
2. The second line of the script simulates pressing your Edit button which
should cause a postback.

Eliyahu.

Mike said:
I want to double click on a row within the grid and have it take me to a
edit screen for that row.
Currently I allow the user highlight a row and click the Edit Button and
that takes them to a edit screen,
can I have it work the same way if they double click the row?
 

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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top