Showing posts with label highlight the selected row. Show all posts
Showing posts with label highlight the selected row. Show all posts

Tuesday, 21 June 2016

highlight the selected row in gridview using Jquery

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>