gridView row selected

I

imbirek8

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
 
A

Amrit Ranjan

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top