Hi,
Textbox wise search database data bind gridview using jquery datatable plugin but data bind with header also bind gridview,so avoid Header in gridview row
Jquery Script:
- <%--animated Zoom In--%>
- <%--for gridview search,sort,paging--%>
- "text/css" href="Design/css/dataTables.bootstrap.min.css" rel="stylesheet" />
- "text/css" href="Design/css/responsive.bootstrap.min.css" rel="stylesheet" />
- <%--for gridview search,sort,paging--%>
- "Design/bootstrap-3.3.7-dist/css/bootstrap.css" rel="stylesheet" />
- "server" ID="txtCountry" />
- "btnSearch" Text="Search" runat="server" />
- class="table-responsive">
- class="table-wrapper">
- "gvCustomers" CssClass="table table-striped table-bordered table-hover" runat="server" AutoGenerateColumns="false">
- "ContactName" HeaderText="Contact Name" />
- "CustomerID" HeaderText="CustomerID" />
- "City" HeaderText="City" />
- "Country" HeaderText="Country" />
Code:
- private void BindGridView()
- {
- string strConnString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
- using (SqlConnection con = new SqlConnection(strConnString))
- {
- SqlCommand cmd = new SqlCommand("SELECT ContactName,CustomerId,City,CompanyName [Country] FROM Customers", con);
- using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
- {
- using (DataSet ds = new DataSet())
- {
- sda.Fill(ds, "Customers");
- gvCustomers.DataSource = ds;
- gvCustomers.DataBind();
- }
- }
- }
- }
- [System.Web.Services.WebMethod]
- public static string GetCustomers(string searchTerm)
- {
- DataSet ds = new DataSet();
- string strConnString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
- SqlConnection con = new SqlConnection(strConnString);
- string query = "SELECT ContactName,CustomerId,City, CompanyName [Country] FROM Customers";
- if (!string.IsNullOrEmpty(searchTerm))
- {
- query += " WHERE CompanyName LIKE '" + searchTerm + "%'";
- }
- SqlCommand cmd = new SqlCommand(query, con);
- cmd.CommandType = CommandType.Text;
- SqlDataAdapter sda = new SqlDataAdapter(cmd);
- sda.Fill(ds, "Customers");
- return ds.GetXml();
- }

Answers
Know the answer? Post it. Somebody with the same question will find it here.