gridView row selected

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • imbirek8

    #1

    gridView row selected

    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

  • Amrit Ranjan

    #2
    Re: gridView row selected

    On Oct 21, 3:47 pm, "imbirek8" <imbir...@op.pl 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.getEl ementById("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.lengt h; i++)
    {
    oGrd.rows[i].onclick = onrowclick;//Bind the click event for each
    row
    if(i % 2 == 0)//setting row color alternate
    oGrd.rows[i].style.backgrou ndColor = "green";
    else
    oGrd.rows[i].style.backgrou ndColor = "yellow";

    }
    }

    function onrowclick(oRow )
    {
    alert(oRow.rowI ndex);
    }


    please check this and if it is working fine then easily you can delete
    row. Other wise I will help you.

    Comment

    Working...