vineshkumar v

vineshkumar v

  • NA
  • 305
  • 429

Gridview bind, searching and pagination for jquery using asp.net

Mar 11 2021 9:50 AM
Gridview bind, searching and pagination for jquery using asp.net

Answers (2)

1
Sachin Singh

Sachin Singh

  • 7
  • 55.8k
  • 83.6k
Mar 11 2021 2:44 PM
you don't need to implement paging, seraching and sorting explicitly just bind your gridview with database data and then apply $("#Gridview1").datatable(); script , this will convert the grid into jquery dataTable.
  1. use jquery datatable, and bind GridView in code behind also set thead and tbody in RowDataBound event  
  2.   
  3.      <form id="form1" runat="server">    
  4.         <div>    
  5.             <asp:GridView ID="GridView1" runat="server" OnRowDataBound="GridView1_RowDataBound"></asp:GridView>    
  6.         </div>    
  7.         </form>    
  8.         <script src="Script/Jquery.js"></script>    
  9.         <script type="text/javascript" src="https://cdn.datatables.net/1.10.9/js/jquery.dataTables.min.js"></script>    
  10.     <link type="text/css" rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css" />    
  11.         
  12.         
  13.         
  14.     <script type="text/javascript">    
  15.         $(document).ready(function () {    
  16.             $('#<%= GridView1.ClientID %>').DataTable();    
  17.         });    
  18.     </script>    
  19.     protected void Page_Load(object sender, EventArgs e)    
  20.             {    
  21.                BindGrid();    
  22.             }    
  23.      protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)    
  24.             {    
  25.                 if (e.Row.RowType == DataControlRowType.Header)    
  26.                 {    
  27.                     //add the thead and tbody section programatically    
  28.                     e.Row.TableSection = TableRowSection.TableHeader;    
  29.                 }    
  30.             }   
  31.   
  32.    
  33.   
 visit this
https://www.c-sharpcorner.com/forums/implement-pagination-and-search-in-asp-net-gridview
1
Rijwan Ansari

Rijwan Ansari

  • 4
  • 65k
  • 3m
Mar 11 2021 1:03 PM
Use JQuery datatable
https://datatables.net/