Home > ASP.Net > Get a value from the a GridView’s row with client side script

Get a value from the a GridView’s row with client side script


Hi

try this example with Gridview control

void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
    e.Row.Attributes.Add("onMouseOver", "this.style.background='#ff0000'");
    e.Row.Attributes.Add("onMouseOut", "this.style.background='#ffffff'");
    if (e.Row.Cells != null && e.Row.Cells.Count > 1)
    {
        e.Row.Attributes.Add("onClick", "alert('Selected value: " + e.Row.Cells[1].Text + "')");
    }
}

Good Luck

Advertisements
Categories: ASP.Net
  1. sergeos
    February 7, 2009 at 7:18 pm

    Thank you!
    So, if gvw alternative row color different than primary row color, after mouseover all rows set to this.style.background=’#ffffff’

    Maybe, possible save of state background color before applying color?

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: