SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 142 | Next

Joydip Kanjilal

"ASP.NET Data Presentation Controls Essentials"


Chapter 6
[ 149 ]
To achieve this; it is simple. Use the following code in the RowDataBound event
handler to set up the JavaScript() method to be called when any of the rows of the
GridView control is clicked. The name of this method is ChangeGridRowColor().
Following is the complete source for the RowDataBound event handler.
protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
e.Row.Attributes["onclick"] =
"javascript:ChangeGridRowColor(this);";
}
The JavaScript() method ChangeGridRow is given as follows:
function ChangeGridRowColor(element)
{
if(element.style.backgroundColor == 'cyan')
element.style.backgroundColor='deepskyblue';
else
element.style.backgroundColor='cyan';
}
Displaying Views of Data (Part I)
[ 150 ]
Changing row color of the GridView control using JavaScript when the
mouse moves over the control's rows
We can also change the color of a row in the GridView as and when you
move the mouse pointer from one row to the other. You need to write the
following code in the RowDataBound event handler of the control.
protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.
DataRow)
{
e.Row.Attributes["onmouseover"] =
"javascript:ToggleRowColor(this);";
e.


Pages:
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6