469,325 Members | 1,491 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,325 developers. It's quick & easy.

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

Oct 21 '08 #1
1 5403
On Oct 21, 3:47*pm, "imbirek8" <imbir...@op.plwrote:
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[i].onclick = onrowclick;//Bind the click event for each
row
if(i % 2 == 0)//setting row color alternate
oGrd.rows[i].style.backgroundColor = "green";
else
oGrd.rows[i].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.
Oct 21 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by mosscliffe | last post: by
reply views Thread by Child X | last post: by
reply views Thread by CK | last post: by
1 post views Thread by shapper | last post: by
1 post views Thread by Dinu | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by Gurmeet2796 | last post: by
reply views Thread by mdpf | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.