Click a row on a datagrid to call SelectedIndexChanged event c#

Discussion in 'ASP .Net Datagrid Control' started by JC, Apr 30, 2004.

  1. JC

    JC Guest

    Hi!

    I have a datagrid in c#. When you move the mouse over the lines they
    highlight. What I really want is for the user to be able to click
    anywhere on a line and the 'SelectedIndexChanged' event be called -
    enabling me to open another page to edit that selected record.

    So, firstly I added a bound Select button, and as expected when I
    click the SelectedIndexChanged event gets called, next stage was to
    make that button invisible but add the following code to the datagrid
    ItemDataBound event...

    //This highlights on mouse over - works fine!
    e.Item.Attributes.Add("onmouseover",
    "this.style.backgroundColor='Silver';this.style.color='white';this.style.cursor='hand'");

    //this unhighlights on mouseout - works fine also!
    e.Item.Attributes.Add("onmouseout",
    "this.style.backgroundColor='white';this.style.color='black';this.style.cursor='hand'");

    //this calls the doPostBakc function passing parameters just as the
    'select' button does, but it doesnt call the SelectedIndexChanged
    event :'(
    e.Item.Attributes.Add("onclick","javascript:__doPostBack('" +
    "dgAllPosts:" + "_ctl" + 1 + ":_ctl0','')");


    Anyways, if anyone can see what I'm doing wrong, or has a better way
    to achieve this, I'd love to hear from you.

    Thanks chaps

    James
     
    JC, Apr 30, 2004
    #1
    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. Purvi T
    Replies:
    0
    Views:
    848
    Purvi T
    Oct 19, 2004
  2. Chu
    Replies:
    2
    Views:
    909
    Winista
    Apr 10, 2006
  3. Max2006
    Replies:
    2
    Views:
    1,577
    Walter Wang [MSFT]
    Sep 19, 2007
  4. dave

    stumped...table - row - click event, cancel checkbox event

    dave, Sep 2, 2006, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    225
  5. Eric
    Replies:
    1
    Views:
    191
    Steve Goodyear
    May 21, 2005
Loading...

Share This Page