HighTechTalks DotNet Forums  

double click on grid

ASP.net Data Grid Control microsoft.public.dotnet.framework.aspnet.datagridcontrol


Discuss double click on grid in the ASP.net Data Grid Control forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Mike
 
Posts: n/a

Default double click on grid - 06-22-2004 , 02:03 PM






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?




Reply With Quote
  #2  
Old   
Eliyahu Goldin
 
Posts: n/a

Default Re: double click on grid - 06-23-2004 , 06:19 AM






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" <anonymous (AT) discussions (DOT) microsoft.com> wrote

Quote:
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?






Reply With Quote
  #3  
Old   
Mike
 
Posts: n/a

Default Re: double click on grid - 06-23-2004 , 07:51 AM



thanks i'll give this a shot
"Eliyahu Goldin" <removemeegoldin (AT) monarchmed (DOT) com> wrote

Quote:
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" <anonymous (AT) discussions (DOT) microsoft.com> wrote in message
news:Or7l3MIWEHA.4048 (AT) TK2MSFTNGP12 (DOT) phx.gbl...
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?








Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.