How to highlight the selected row in gridview using Jquery
<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
//click on row
$("#<%=gdv1.ClientID%> tr:has(td)").click(function () {
//go through each row of the table
$("#<%=gdv1.ClientID%> tr").each(function () {
//set the all rows's default background
$(this).parent().children().removeClass("selection");
});
$(this).addClass("selection");
}, function () {
// $(this).parent().children().removeClass("selection");
$(this).addClass("selection");
});
});
</script>
<style type="text/css">
.selection
{
background-color:Gray;
border :1px groove #888888;
color:White;
}
</style>
<asp:GridView ID="gdv1" runat="server">
</asp:GridView>
<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
//click on row
$("#<%=gdv1.ClientID%> tr:has(td)").click(function () {
//go through each row of the table
$("#<%=gdv1.ClientID%> tr").each(function () {
//set the all rows's default background
$(this).parent().children().removeClass("selection");
});
$(this).addClass("selection");
}, function () {
// $(this).parent().children().removeClass("selection");
$(this).addClass("selection");
});
});
</script>
<style type="text/css">
.selection
{
background-color:Gray;
border :1px groove #888888;
color:White;
}
</style>
<asp:GridView ID="gdv1" runat="server">
</asp:GridView>
No comments:
Post a Comment