If so,
the employee name corresponding to that record is displayed. Following is the code
for the event handler for the Click event of the button control.
protected void btnClick_Click(object sender, EventArgs e)
{
Response.Write("The following employees have been selected:--
");
for (int i = 0; i < GridView1.Rows.Count; i++)
{
Displaying Views of Data (Part I)
[ 148 ]
if (((CheckBox)GridView1.Rows[i].FindControl
("chkSelect")).Checked)
{
Response.Write("
" + GridView1
.Rows[i].Cells[3].Text);
}
}
}
Note that we have used the FindControl() method as usual to retrieve a reference
to the CheckBox control of each of the rows of the GridView control. In the next
section we will learn how we can display tool tips in a GridView control.
Change the Row Color of GridView Control
Using JavaScript
We will now explore how we can change the color of a GridViewRow using
JavaScript. First, let us understand how we can change the row color in the Click
event of any particular row of the GridView control. Following is a screenshot that
illustrates that the color of the clicked row has been changed.
When the same row is clicked again, the original color is displayed for that row.
Following is the output when you click on the same row for which the color has been
changed on account of the Click.
Pages:
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153