gridView row selected

Discussion in 'Javascript' started by imbirek8, Oct 21, 2008.

  1. imbirek8

    imbirek8 Guest

    Hi,

    I use GridView control in asp.net.
    I would like to write an event on the client site. When somebody click on
    row, I would like to clear all selected rows in GridView and changed cliked
    row color in permanent way.
    How to do it in JavaScript ?

    Thank you for help
     
    imbirek8, Oct 21, 2008
    #1
    1. Advertising

  2. imbirek8

    Amrit Ranjan Guest

    On Oct 21, 3:47 pm, "imbirek8" <> wrote:
    > Hi,
    >
    > I use GridView control in asp.net.
    > I would like to write an event on the client site. When somebody click on
    > row, I would like to clear all selected rows in GridView and changed cliked
    > row color in permanent way.
    > How to do it in JavaScript ?
    >
    > Thank you for help


    Yes it is possible. ASP.NET grid view is nothing but HTML table at
    client side.
    You have to write some script to bind all events to the grid (i.e.
    HTML table) once body load complete. Like on body load

    function onbodyload()
    {
    var oGrd = docuement.getElementById("grid view name");//grid name
    some time changes if you are using master page or user control.
    //You could do same thing at grid click level but again you have to
    play with srcElement of IE or //target for Moz as well as nodeName
    for(var i = 0; i < oGrd.rows.length; i++)
    {
    oGrd.rows.onclick = onrowclick;//Bind the click event for each
    row
    if(i % 2 == 0)//setting row color alternate
    oGrd.rows.style.backgroundColor = "green";
    else
    oGrd.rows.style.backgroundColor = "yellow";

    }
    }

    function onrowclick(oRow)
    {
    alert(oRow.rowIndex);
    }


    please check this and if it is working fine then easily you can delete
    row. Other wise I will help you.
     
    Amrit Ranjan, Oct 21, 2008
    #2
    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. =?Utf-8?B?U3VyZXNo?=
    Replies:
    1
    Views:
    469
    Saravana
    Nov 22, 2004
  2. H5N1
    Replies:
    0
    Views:
    2,724
  3. Replies:
    5
    Views:
    667
  4. Want to add row under selected row of gridview

    , Feb 16, 2007, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    304
  5. Selected Row Only GridView Row Visible?

    , Oct 17, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    298
Loading...

Share This Page