Dear Experts,
I tried to modify downloaded code from http://aspsnippets.com/Articles/Search-GridView-records-data-on-TextBox-KeyPress-using-jQuery-in-ASPNet.aspx to use with content pages/ master page by placing javascript at master page and put below code at the content page, But the when i type somethng on the text nothing filters.
Looking for your valuable suggestions or any other link to get an idea to filter gridivew using master page.
* I am using VS 2005
* GVPRFInquiry => Gridivew
* PR.PRFInquiry(BadgeNo) => return dataset containing results
* txtSearch => text box created at the top of gridview.
Below query brings data to the gridivew on page load.
If Not Me.IsPostBack Then
Dim ds As New DataSet
ds = PR.PRFInquiry(BadgeNo)
GVPRFInquiry.DataSource = ds
GVPRFInquiry.DataMember = "DataSet"
GVPRFInquiry.DataBind()
End If
below code create text box inside gridview to filter and calls the javascript.
Protected Sub OnDataBound(ByVal sender As Object, ByVal e As EventArgs)
If (Not Master.Page.ClientScript.IsStartupScriptRegistered("function")) Then
Master.Page.ClientScript.RegisterStartupScript(Me.GetType(), "function", "fucntion();", True)
End If
Dim row As New GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Normal)
For i As Integer = 0 To GVPRFInquiry.Columns.Count - 1
Dim cell As New TableHeaderCell()
Dim txtSearch As New TextBox()
txtSearch.Attributes("placeholder") = GVPRFInquiry.Columns(i).HeaderText
txtSearch.CssClass = "search_textbox"
cell.Controls.Add(txtSearch)
row.Controls.Add(cell)
Next
GVPRFInquiry.HeaderRow.Parent.Controls.AddAt(1, row)
End Sub
<asp:GridView ID="GVPRFInquiry" runat="server" BackColor="AntiqueWhite" BorderColor="Black"
CellPadding="3" ForeColor="Black" Font-Size="8pt" Font-Names="verdana" AutoGenerateColumns="False"
Width="799px" OnDataBound="OnDataBound">
<Columns>
<asp:BoundField DataField="PRFNo" HeaderText="PRF No" InsertVisible="False" ReadOnly="True">
<HeaderStyle Wrap="False" />
<ItemStyle Width="100px" />
</asp:BoundField>
<asp:BoundField DataField="RequestedDate" HeaderText="Requested Date" DataFormatString="{0:d}"
HtmlEncode="False" SortExpression="Name">
<HeaderStyle Wrap="False" />
<ItemStyle Width="150px" />
<ControlStyle Width="150px" />
</asp:BoundField>
</Columns>
<FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
<PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
<HeaderStyle BackColor="InactiveCaption" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>