I am refering this article :
http://aspsnippets.com/Articles/Search-GridView-records-data-on-TextBox-KeyPress-using-jQuery-in-ASPNet.aspx
now when i type something in header Search cell , it shows the data of first page index only , it won't show me data from 2nd page index .. here's my code :
protected void PhasesTempGrid_OnDataBound(object sender, EventArgs e)
{
GridViewRow row = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Normal);
for (int i = 0; i < PhasesTempGrid.Columns.Count - 1; i++)
{
TableHeaderCell cell = new TableHeaderCell();
TextBox txtSearch = new TextBox();
txtSearch.Attributes["placeholder"] = "Search Here.";
txtSearch.CssClass = "search_textbox";
cell.Controls.Add(txtSearch);
row.Controls.Add(cell);
}
PhasesTempGrid.HeaderRow.Parent.Controls.AddAt(1, row);
}
My gridview is in update panel therefore i did this in .js script :
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(function () {
$(document).ready(function () {
$('.search_textbox').each(function (i) {
$(this).quicksearch("[id$='PhasesTempGrid'] tr:not(:has(th))", {
'testQuery': function (query, txt, row) {
return $(row).children(":eq(" + i + ")").text().toLowerCase().indexOf(query[0].toLowerCase()) != -1;
}
});
});
});
});
Here's my code structure for gridview :
<asp:UpdatePanel ID="ConstructionActPhaseUpdatePanel" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<asp:gridview ID="PhasesTempGrid" ClientIDMode="Static" OnDataBound="PhasesTempGrid_OnDataBound" allowpaging="True" OnPageIndexChanging="PhasesTempGrid_OnPageIndexChanging" PageSize = "5" PagerStyle-CssClass="custompaging" AllowSorting="True" runat="server" AutoGenerateColumns="False" CssClass="table table-bordered" BackColor="White" ForeColor="Black" BorderStyle="Groove" ShowFooter="True" >
<Columns>
<asp:TemplateField HeaderText="Activity Code">
<ItemTemplate>
<asp:Label ID="ACodeLabel" runat="server" Text='<%#Eval("ACode") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Activity Sequence">
<ItemTemplate>
<asp:Label ID="ASeqLabel" runat="server" Text='<%#Eval("ASeq") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Construction Phase">
<ItemTemplate>
<asp:Label ID="CPhaseTempLabel" runat="server" Text='<%#Eval("CPhase") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Activity Description / Name">
<ItemTemplate>
<asp:Label ID="ADescLabel" runat="server" Text='<%#Eval("ADesc") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="RemoveRow" CssClass="btn btn-blue btn-block" OnClick="RemoveRow_OnClick" runat="server" >Remove</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle CssClass="panel-heading" />
<PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" />
<HeaderStyle CssClass="customGridViewHeader" ForeColor="black"/>
</asp:gridview>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="AddRowBTN" EventName="ServerClick" />
<asp:AsyncPostBackTrigger ControlID="SubmitBtn" EventName="ServerClick" />
<asp:AsyncPostBackTrigger ControlID="PhasesTempGrid"/>
</Triggers>
</asp:UpdatePanel>
and the way i bind the data to gridview is from textboxes ....
refer my this question ,
http://www.aspforums.net/Threads/509076/How-to-create-a-GridView-dynamically-and-show-temporary-data-from-Textboxes-to-GridView-in-ASPNet/
the answer which azim gave was perfect , i used that article here ...