Hi Richa,
I have created a sample which full fill your requirement
SQL
CREATE TABLE [BootStrapSearch]
(
[Code] [int] NULL,
[Description] [nvarchar](50) NULL,
[EntityStatus] [nchar](10) NULL
)
HTML
<div>
<div class="row" style="margin-top: 20px;">
<div class="col-lg-6">
<div class="input-group">
<div class="input-group-btn search-panel">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<span id="search_concept">Name</span> <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="#contains">Contains</a></li>
<li><a href="#its_equal">It's equal</a></li>
<li><a href="#greather_than">Greather than ></a></li>
<li><a href="#less_than">Less than < </a></li>
<li class="divider"></li>
<li><a href="#all">Anything</a></li>
</ul>
</div>
<input type="hidden" name="search_param" id="searchParam" value="all" id="search_param">
<input type="text" class="form-control" id="searchTerm" name="x" style="width: 200px;"
placeholder="Search..">
<button class="btn btn-default" id="search" type="button">
<span class="glyphicon glyphicon-search"></span>
</button>
</div>
</div>
</div>
<div class="row" style="margin-top: 20px;">
<div class="col-lg-11">
<div class="rounded_corners">
<asp:GridView ID="GridView1" runat="server" CssClass="Grid" AutoGenerateColumns="false">
<Columns>
<asp:BoundField HeaderText="Code" DataField="Code" />
<asp:BoundField HeaderText="Description" DataField="Description" />
<asp:BoundField HeaderText="EntityStatus" DataField="EntityStatus" />
</Columns>
</asp:GridView>
</div>
</div>
</div>
</div>
<div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/json2/20130526/json2.min.js"></script>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" />
<script type="text/javascript">
$(function () {
$('a').click(function () {
$('[id*=searchParam]').val($(this)[0].innerHTML);
});
$('#search').click(function () {
var obj = {};
obj.searchParam = $('[id*=searchParam]').val();
obj.searchTerm = $('[id*=searchTerm]').val();
$.ajax({
type: "POST",
url: "Default.aspx/FilteredRecords",
data: JSON.stringify(obj),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess
});
});
});
function OnSuccess(response) {
var xmlDoc = $.parseXML(response.d);
var xml = $(xmlDoc);
var bootStrapSearchs = xml.find("BootStrapSearch");
var row = $("[id*=GridView1] tr:last-child").clone(true);
$("[id*=GridView1] tr").not($("[id*=GridView1] tr:first-child")).remove();
$.each(bootStrapSearchs, function () {
$("td", row).eq(0).html($(this).find("Code").text());
$("td", row).eq(1).html($(this).find("Description").text());
$("td", row).eq(2).html($(this).find("EntityStatus").text());
$("[id*=GridView1]").append(row);
row = $("[id*=GridView1] tr:last-child").clone(true);
});
};
</script>
</div>
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindGrid();
}
}
private void BindGrid()
{
string constr = ConfigurationManager.ConnectionStrings["conString"].ConnectionString;
SqlConnection con = new SqlConnection(constr);
string query = "SELECT Code,[Description],EntityStatus FROM BootStrapSearch";
SqlCommand cmd = new SqlCommand(query, con);
DataTable dt = new DataTable();
SqlDataAdapter sda = new SqlDataAdapter(cmd);
sda.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
}
[WebMethod]
public static string FilteredRecords(string searchParam, string searchTerm)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conString"].ConnectionString);
string query = "SELECT Code,[Description],EntityStatus FROM BootStrapSearch ";
switch (searchParam.ToLower().Trim())
{
case "contains":
query += "WHERE Code LIKE '%" + searchTerm + "%'";
break;
case "it's equal":
query += "WHERE Code = '" + searchTerm + "'";
break;
case "greather than >":
query += "WHERE Code > '" + searchTerm + "'";
break;
case "less than <":
query += "WHERE Code < '" + searchTerm + "'";
break;
case "anything":
query = "SELECT Code,[Description],EntityStatus FROM BootStrapSearch";
break;
default:
break;
}
SqlCommand cmd = new SqlCommand(query, con);
DataSet ds = new DataSet();
SqlDataAdapter sda = new SqlDataAdapter(cmd);
sda.Fill(ds);
ds.Tables[0].TableName = "BootStrapSearch";
return ds.GetXml();
}
ScreenShot
Hope this works for you