double click on grid

Discussion in 'ASP .Net Datagrid Control' started by Mike, Jun 22, 2004.

  1. Mike

    Mike Guest

    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?
     
    Mike, Jun 22, 2004
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:...
    > 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?
    >
    >
    >
     
    Eliyahu Goldin, Jun 23, 2004
    #2
    1. Advertising

  3. Mike

    Mike Guest

    thanks i'll give this a shot
    "Eliyahu Goldin" <> wrote in message
    news:...
    > 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" <> wrote in message
    > news:...
    > > 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?
    > >
    > >
    > >

    >
    >
     
    Mike, Jun 23, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Girish
    Replies:
    4
    Views:
    672
    Patrick.O.Ige
    Jul 19, 2005
  2. =?Utf-8?B?QXNzYW5LaGFuIElzbWFpbA==?=

    How to transfer a value from an Invisible Grid to an visible Grid

    =?Utf-8?B?QXNzYW5LaGFuIElzbWFpbA==?=, Oct 13, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    472
    =?Utf-8?B?QXNzYW5LaGFuIElzbWFpbA==?=
    Oct 17, 2005
  3. Danny Tuppeny

    Grouped grid? Or grid within datalist?

    Danny Tuppeny, Oct 27, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    501
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
    Oct 27, 2005
  4. Sydex
    Replies:
    12
    Views:
    6,505
    Victor Bazarov
    Feb 17, 2005
  5. Replies:
    0
    Views:
    374
Loading...

Share This Page