Hi friends...
Am using a Gridview and whenever mousehover on the row of gridview am changing the color of row. now i want to change the color of row when i select the gridview row.. how to do it... plz help me ...
protected void GridViewStudentList_RowCreated(object sender, GridViewRowEventArgs e)
{
// only apply changes if its DataRow
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover",
"this.originalstyle=this.style.backgroundColor;this.style.backgroundColor='#FF9955'");
e.Row.Attributes.Add("onmouseout",
"this.style.backgroundColor=this.originalstyle;");
}
}
//This is an HTML code...
<asp:GridView ID="GridViewStudentList" SelectedRowStyle-ForeColor="#FBA16C" OnRowCreated="GridViewStudentList_RowCreated"
runat="server" Width="100%" CellPadding="4" ForeColor="#333333" GridLines="None"
AutoGenerateColumns="false">
<RowStyle BackColor="#EFF3Ff" />
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<asp:Label ID="Label1" runat="server" Text="Name"></asp:Label>
</HeaderTemplate>
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" Text='<%# DataBinder.Eval(Container.DataItem,"FirstName")%>'
CommandArgument='<%# DataBinder.Eval(Container.DataItem, "StudentId")%>' OnClick="lnkStudent_Click"
runat="server"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<asp:Label ID="Label1" runat="server" Text="Class Name"></asp:Label>
</HeaderTemplate>
<ItemTemplate>
<asp:LinkButton ID="LinkButton2" ForeColor="BurlyWood" Text='<%# DataBinder.Eval(Container.DataItem,"ClassTitle")%>'
CommandArgument='<%# DataBinder.Eval(Container.DataItem, "StudentId")%>' OnClick="lnkStudent_Click"
runat="server"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<%--<Columns>
<asp:BoundField DataField="ClassId" HeaderText="Class Id"
ControlStyle-CssClass="nameFont" >
<ControlStyle CssClass="nameFont" />
</asp:BoundField>
</Columns>--%>
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5F9EA0" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#2461BF" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>