Please refer this code
Ref
HTML
<asp:GridView ID="GridView1" HeaderStyle-BackColor="#3AC0F2" HeaderStyle-ForeColor="White"
runat="server" AutoGenerateColumns="false" OnDataBound="OnDataBound">
<Columns>
<asp:BoundField DataField="Id" HeaderText="Id" ItemStyle-Width="30" />
<asp:BoundField DataField="Name" HeaderText="Name" ItemStyle-Width="100" />
<asp:BoundField DataField="Country" HeaderText="Country" ItemStyle-Width="100" />
</Columns>
</asp:GridView>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="quicksearch.js"></script>
<script type="text/javascript">
$(function () {
$('.search_textbox').each(function (i) {
$(this).quicksearch("[id*=GridView1] tr:not(:has(th))", {
'testQuery': function (query, txt, row) {
if ($('.search_textbox').eq(i).attr('placeholder') == "Name") {
return $(row).children(":eq(" + 1 + ")").text().toLowerCase().indexOf(query[0].toLowerCase()) != -1;
}
else if ($('.search_textbox').eq(i).attr('placeholder') == "Country") {
return $(row).children(":eq(" + 2 + ")").text().toLowerCase().indexOf(query[0].toLowerCase()) != -1;
}
}
});
});
});
</script>
Namespace
Imports System.Data
VB.Net
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
Dim dt As New DataTable()
dt.Columns.AddRange(New DataColumn(2) {New DataColumn("Id", GetType(Integer)), New DataColumn("Name", GetType(String)), New DataColumn("Country", GetType(String))})
dt.Rows.Add(1, "John Hammond", "United States")
dt.Rows.Add(2, "Mudassar Khan", "India")
dt.Rows.Add(3, "Suzanne Mathews", "France")
dt.Rows.Add(4, "Robert Schidner", "Russia")
GridView1.DataSource = dt
GridView1.DataBind()
End If
End Sub
Protected Sub OnDataBound(sender As Object, e As EventArgs)
Dim row As New GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Normal)
For i As Integer = 0 To GridView1.Columns.Count - 1
Dim cell As New TableHeaderCell()
If i <= GridView1.Columns.Count - 1 AndAlso i > 0 Then
Dim txtSearch As New TextBox()
txtSearch.Attributes("placeholder") = GridView1.Columns(i).HeaderText
txtSearch.CssClass = "search_textbox"
cell.Controls.Add(txtSearch)
End If
row.Controls.Add(cell)
Next
GridView1.HeaderRow.Parent.Controls.AddAt(1, row)
End Sub
Screenshot