ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Bind ASP.Net Repeater and display Bootstrap DataTable search result using jQuery in ASP.Net<p>Hi&nbsp;Waghmare,</p> <p>Check this example. Now please take its reference and correct your code.</p> <p><span style="text-decoration: underline;"><strong>Database</strong></span></p> <p>For this example I have used of Northwind database that you can download using the link given below.</p> <p><a href="https://www.aspsnippets.com/Articles/Install-Microsoft-Northwind-and-Pubs-Sample-databases-in-SQL-Server-Management-Studio.aspx" target="_blank">Download Northwind Database</a></p> <p><span style="text-decoration: underline;"><strong>HTML</strong></span></p> <pre class="brush: html">&lt;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;&gt; &lt;head runat=&#34;server&#34;&gt; &lt;title&gt;&lt;/title&gt; &lt;link type=&#34;text/css&#34; rel=&#34;stylesheet&#34; href=&#34;https://cdn.datatables.net/1.10.9/css/dataTables.bootstrap.min.css&#34; /&gt; &lt;link type=&#34;text/css&#34; rel=&#34;stylesheet&#34; href=&#34;https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css&#34; /&gt; &lt;link type=&#34;text/css&#34; rel=&#34;stylesheet&#34; href=&#34;https://cdn.datatables.net/responsive/1.0.7/css/responsive.bootstrap.min.css&#34; /&gt; &lt;script type=&#34;text/javascript&#34; src=&#34;https://code.jquery.com/jquery-1.12.4.js&#34;&gt;&lt;/script&gt; &lt;script type=&#34;text/javascript&#34; src=&#34;https://cdn.datatables.net/1.10.9/js/jquery.dataTables.min.js&#34;&gt;&lt;/script&gt; &lt;script type=&#34;text/javascript&#34; src=&#34;https://cdn.datatables.net/responsive/1.0.7/js/dataTables.responsive.min.js&#34;&gt;&lt;/script&gt; &lt;script type=&#34;text/javascript&#34; src=&#34;https://cdn.datatables.net/1.10.9/js/dataTables.bootstrap.min.js&#34;&gt;&lt;/script&gt; &lt;script type=&#34;text/javascript&#34; src=&#34;https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js&#34;&gt;&lt;/script&gt; &lt;script type=&#34;text/javascript&#34;&gt; $(function () { var table = $(&#39;[id*=gvCustomers]&#39;).prepend($(&#34;&lt;thead&gt;&lt;/thead&gt;&#34;).append($(this).find(&#34;tr:first&#34;))).DataTable({ &#34;responsive&#34;: false, &#34;sPaginationType&#34;: &#34;full_numbers&#34;, &#34;bPaginate&#34;: true, &#34;bSort&#34;: true, &#34;iDisplayLength&#34;: 5, &#34;stateSave&#34;: false, &#34;stateDuration&#34;: 60 * 1 }); var repeaterTBody; table.on(&#39;search.dt&#39;, function () { if (repeaterTBody == null) { repeaterTBody = $(&#34;#dvCustomers table&#34;).eq(0).clone(true); } $(&#34;#dvCustomers&#34;).empty(); if (table.rows({ filter: &#39;applied&#39; }).data().length &gt; 0) { for (var i = 0; i &lt; table.rows({ filter: &#39;applied&#39; }).data().length; i++) { $(&#34;.id&#34;, repeaterTBody).html(table.rows({ filter: &#39;applied&#39; }).data()[i][0]); $(&#34;.name&#34;, repeaterTBody).html(table.rows({ filter: &#39;applied&#39; }).data()[i][1]); $(&#34;.country&#34;, repeaterTBody).html(table.rows({ filter: &#39;applied&#39; }).data()[i][2]); $(&#34;#dvCustomers&#34;).append(&#34;&lt;table&gt;&#34; + repeaterTBody.html().trim() + &#34;&lt;/table&gt;&#34;); repeaterTBody = $(&#34;#dvCustomers table&#34;).eq(0).clone(true); } } else { var empty_row = repeaterTBody.clone(true); $(&#34;td:first-child&#34;, empty_row).attr(&#34;colspan&#34;, $(&#34;td&#34;, repeaterTBody).length); $(&#34;td:first-child&#34;, empty_row).attr(&#34;align&#34;, &#34;center&#34;); $(&#34;td:first-child&#34;, empty_row).html(&#34;No matching records found&#34;); $(&#34;td&#34;, empty_row).not($(&#34;td:first-child&#34;, empty_row)).remove(); $(&#34;#dvCustomers&#34;).append(empty_row); } }) }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id=&#34;form1&#34; runat=&#34;server&#34;&gt; &lt;asp:GridView ID=&#34;gvCustomers&#34; runat=&#34;server&#34; AutoGenerateColumns=&#34;false&#34; class=&#34;table table-striped&#34; Width=&#34;100%&#34;&gt; &lt;Columns&gt; &lt;asp:BoundField DataField=&#34;CustomerID&#34; HeaderText=&#34;Customer ID&#34; /&gt; &lt;asp:BoundField DataField=&#34;ContactName&#34; HeaderText=&#34;Name&#34; /&gt; &lt;asp:BoundField DataField=&#34;Country&#34; HeaderText=&#34;Country&#34; /&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt; &lt;br /&gt; &lt;div id=&#34;dvCustomers&#34;&gt; &lt;asp:Repeater ID=&#34;rptCustomers&#34; runat=&#34;server&#34;&gt; &lt;ItemTemplate&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt;&lt;span class=&#34;id&#34;&gt;&lt;%# Eval(&#34;CustomerID&#34;)%&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span class=&#34;name&#34;&gt;&lt;%# Eval(&#34;ContactName&#34;) %&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span class=&#34;country&#34;&gt;&lt;%# Eval(&#34;Country&#34;) %&gt;&lt;/span&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/ItemTemplate&gt; &lt;/asp:Repeater&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt;</pre> <p><strong><span style="text-decoration: underline;">Namespaces</span></strong></p> <p><strong>C#</strong></p> <pre class="brush: csharp">using System.Configuration; using System.Data; using System.Data.SqlClient;</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Imports System.Configuration Imports System.Data Imports System.Data.SqlClient</pre> <p><strong><span style="text-decoration: underline;">Code</span></strong></p> <p><strong>C#</strong></p> <pre class="brush: csharp">protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { string constr = ConfigurationManager.ConnectionStrings[&#34;constr&#34;].ConnectionString; using (SqlConnection con = new SqlConnection(constr)) { using (SqlCommand cmd = new SqlCommand(&#34;SELECT TOP 7 CustomerID,ContactName,Country FROM Customers&#34;, con)) { using (SqlDataAdapter sda = new SqlDataAdapter(cmd)) { cmd.CommandType = CommandType.Text; DataTable dt = new DataTable(); sda.Fill(dt); gvCustomers.DataSource = dt; gvCustomers.DataBind(); rptCustomers.DataSource = dt; rptCustomers.DataBind(); } } } } }</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load If Not Me.IsPostBack Then Dim constr As String = ConfigurationManager.ConnectionStrings(&#34;constr&#34;).ConnectionString Using con As SqlConnection = New SqlConnection(constr) Using cmd As SqlCommand = New SqlCommand(&#34;SELECT TOP 7 CustomerID,ContactName,Country FROM Customers&#34;, con) Using sda As SqlDataAdapter = New SqlDataAdapter(cmd) cmd.CommandType = CommandType.Text Dim dt As DataTable = New DataTable() sda.Fill(dt) gvCustomers.DataSource = dt gvCustomers.DataBind() rptCustomers.DataSource = dt rptCustomers.DataBind() End Using End Using End Using End If End Sub</pre> <p><strong><span style="text-decoration: underline;">Screenshot</span></strong></p> <p><strong><span style="text-decoration: underline;"><img src="https://i.imgur.com/KMAirBE.gif" alt="" width="339" height="502" /></span></strong></p>https://www.aspforums.net:443/Threads/111856/Bind-ASPNet-Repeater-and-display-Bootstrap-DataTable-search-result-using-jQuery-in-ASPNet/https://www.aspforums.net:443/Threads/111856/Bind-ASPNet-Repeater-and-display-Bootstrap-DataTable-search-result-using-jQuery-in-ASPNet/Thu, 25 Jul 2019 05:45:14 GMT