如何在文本框中键入时显示gridview的记录 [英] How To Show records of gridview while typing in textbox
问题描述
我已将搜索文本框放在updatepanel界限范围内的手风琴标题中。
更新面板里面我已经放置了gridview,sqldatasource和触发标签。这是我的来源:
I have placed searching text box in accordion header outside bounds of updatepanel.
inside update panel I have placed gridview,sqldatasource and trigger tags.This is my source:
<asp:Content ID="Content2" ContentPlaceHolderID="placecontent" runat="Server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div id="accordion">
<asp:Accordion ID="Accordion1" runat="server" SelectedIndex="-1" FadeTransitions="true" FramesPerSecond="100" AutoSize="None" HeaderCssClass="AccordionHeader" ContentCssClass="AccordionContent" TransitionDuration="200">
<Panes>
<asp:AccordionPane ID="NormalSearch" runat="server">
<Header>
<div align="left">
<asp:Panel ID="PnlSearchAll" runat="server">
<table>
<tr>
<td>
<asp:Label ID="LblSearchAll" runat="server" Text="Search All Columns: " Font-Names="Calibri" Font-Size="Medium"></asp:Label>
</td>
<td>
<asp:TextBox ID="TxtSearch" runat="server" Font-Names="Calibri" Font-Size="Medium" OnTextChanged="TxtSearch_TextChanged"></asp:TextBox>
</td>
</tr>
</table>
</asp:Panel>
</div>
</Header>
<Content>
</Content>
</asp:AccordionPane>
</Panes>
</asp:Accordion>
</div>
<asp:UpdatePanel ID="updtpnl1" runat="server">
<ContentTemplate>
<center>
<center>
<div id="GrdView">
<asp:Panel ID="PnlAdvanced" runat="server">
<center>
<table>
<tr>
<td colspan="2">
<asp:GridView ID="GrdSummery" runat="server" AutoGenerateColumns="False" GridLines="None"
AllowPaging="True"
CssClass="mGrid"
PagerStyle-CssClass="pgr"
AlternatingRowStyle-CssClass="alt" AllowSorting="true" DataSourceID="dsGridview" Width="900px">
<AlternatingRowStyle CssClass="alt" />
<Columns>
<asp:BoundField DataField="companyname" HeaderText="Supplier_Name" SortExpression="companyname">
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="300px" />
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="300px" />
</asp:BoundField>
<asp:BoundField DataField="billno" HeaderText="Bill_No" SortExpression="billno">
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="180px" />
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="180px" />
</asp:BoundField>
<asp:BoundField DataField="totalprice" HeaderText="Total_Price" SortExpression="totalprice">
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="80px" />
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="80px" />
</asp:BoundField>
<asp:BoundField DataField="billdate" HeaderText="Bill_Date" SortExpression="billdate">
<HeaderStyle Font-Names="Calibri" Font-Size="Small" HorizontalAlign="Center" VerticalAlign="Middle" />
<ItemStyle Font-Names="Calibri" Font-Size="Small" HorizontalAlign="Center" VerticalAlign="Middle" />
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</asp:BoundField>
<asp:BoundField DataField="purchasetype" HeaderText="Purchase_Type" SortExpression="purchasetype">
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</asp:BoundField>
<asp:BoundField DataField="extranotes" HeaderText="Remarks" SortExpression="extranotes">
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</asp:BoundField>
</Columns>
<PagerStyle CssClass="pgr" />
</asp:GridView>
<asp:SqlDataSource ID="dsGridview" runat="server" ConnectionString="<%$ ConnectionStrings:akdmbilldbconnectionstring %>"
SelectCommand="SELECT SupplierMaster.companyname,BillMaster.billno,BillMaster.totalprice,BillMaster.purchasetype,BillMaster.extranotes,convert(varchar,BillMaster.billdate,103) as billdate FROM SupplierMaster INNER JOIN BillMaster ON SupplierMaster.companyid = BillMaster.companyid order by BillMaster.billdate ASC" FilterExpression="companyname like '%{0}%' or billno like '%{1}%' or totalprice like '%{2}%' or purchasetype like '%{3}%' or extranotes like '%{4}%' or billdate like '%{5}%'">
<FilterParameters>
<asp:ControlParameter Name="companyname" ControlID="Txtsearch" PropertyName="Text" />
<%--<asp:ControlParameter Name="billid" ControlID="TxtSearch" PropertyName="Text" />--%>
<asp:ControlParameter Name="billno" ControlID="Txtsearch" PropertyName="Text" />
<asp:ControlParameter Name="totalprice" ControlID="Txtsearch" PropertyName="Text" />
<asp:ControlParameter Name="purchasetype" ControlID="Txtsearch" PropertyName="Text" />
<asp:ControlParameter Name="extranotes" ControlID="Txtsearch" PropertyName="Text" />
<asp:ControlParameter Name="billdate" ControlID="Txtsearch" PropertyName="Text" />
</FilterParameters>
</asp:SqlDataSource>
</td>
</tr>
</table>
</center>
</asp:Panel>
</div
>
>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Txtsearch" EventName="TextChanged" />
</Triggers>
</asp:UpdatePanel>
</asp:Content>
Below is My code Behind :
Below is My code Behind :
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
' Find control on page.
TxtSearch.Attributes.Add("onkeyup", "setTimeout('__doPostBack(\'" + TxtSearch.ClientID + "\',\'\')', 0);")
''Dim str As String = TextBox1.ClientID.Replace("_", "$")
If Not IsPostBack Then
GrdSummery.DataBind()
End If
'BtnSearch_Click(sender, e)
' GrdSummery.Visible = True
End Sub
Protected Sub TxtSearch_TextChanged(sender As Object, e As EventArgs) Handles TxtSearch.TextChanged
SearchString = TxtSearch.Text
End Sub
I am getting Error :
Could not find control ’Txtsearch’ in ControlParameter ’companyname’.
Any Help Would be appreciated.
I am getting Error :
Could not find control 'Txtsearch' in ControlParameter 'companyname'.
Any Help Would be appreciated.
推荐答案
ConnectionStrings:akdmbilldbconnectionstring %>\"
SelectCommand=\"SELECT SupplierMaster.companyname,BillMaster.billno,BillMaster.totalprice,BillMaster.purchasetype,BillMaster.extranotes,convert(varchar,BillMaster.billdate,103) as billdate FROM SupplierMaster INNER JOIN BillMaster ON SupplierMaster.companyid = BillMaster.companyid order by BillMaster.billdate ASC\" FilterExpression=\"companyname like '%{0}%' or billno like '%{1}%' or totalprice like '%{2}%' or purchasetype like '%{3}%' or extranotes like '%{4}%' or billdate like '%{5}%'\">
<FilterParameters>
<asp:ControlParameter Name=\"companyname\" ControlID=\"Txtsearch\" PropertyName=\"Text\" />
<%--<asp:ControlParameter Name=\"billid\" ControlID=\"TxtSearch\" PropertyName=\"Text\" />--%>
<asp:ControlParameter Name=\"billno\" ControlID=\"Txtsearch\" PropertyName=\"Text\" />
< asp:ControlParameter Name=\"totalprice\" ControlID=\"Txtsearch\" PropertyName=\"Text\" />
<asp:ControlParameter Name=\"purchasetype\" Co ntrolID=\"Txtsearch\" PropertyName=\"Text\" />
<asp:ControlParameter Name=\"extranotes\" ControlID=\"Txtsearch\" PropertyName=\"Text\"/>
<asp:ControlParameter Name=\"billdate\" ControlID=\"Txtsearch\" PropertyName=\"Text\" />
</FilterParameters>
</a sp:SqlDataSource>
</td>
</tr>
</table>
</center>
</asp:Panel>
</div
ConnectionStrings:akdmbilldbconnectionstring %>" SelectCommand="SELECT SupplierMaster.companyname,BillMaster.billno,BillMaster.totalprice,BillMaster.purchasetype,BillMaster.extranotes,convert(varchar,BillMaster.billdate,103) as billdate FROM SupplierMaster INNER JOIN BillMaster ON SupplierMaster.companyid = BillMaster.companyid order by BillMaster.billdate ASC" FilterExpression="companyname like '%{0}%' or billno like '%{1}%' or totalprice like '%{2}%' or purchasetype like '%{3}%' or extranotes like '%{4}%' or billdate like '%{5}%'"> <FilterParameters> <asp:ControlParameter Name="companyname" ControlID="Txtsearch" PropertyName="Text" /> <%--<asp:ControlParameter Name="billid" ControlID="TxtSearch" PropertyName="Text" />--%> <asp:ControlParameter Name="billno" ControlID="Txtsearch" PropertyName="Text" /> <asp:ControlParameter Name="totalprice" ControlID="Txtsearch" PropertyName="Text" /> <asp:ControlParameter Name="purchasetype" ControlID="Txtsearch" PropertyName="Text" /> <asp:ControlParameter Name="extranotes" ControlID="Txtsearch" PropertyName="Text" /> <asp:ControlParameter Name="billdate" ControlID="Txtsearch" PropertyName="Text" /> </FilterParameters> </asp:SqlDataSource> </td> </tr> </table> </center> </asp:Panel> </div
>
>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Txtsearch" EventName="TextChanged" />
</Triggers>
</asp:UpdatePanel>
</asp:Content>
Below is My code Behind :
Below is My code Behind :
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
' Find control on page.
TxtSearch.Attributes.Add("onkeyup", "setTimeout('__doPostBack(\'" + TxtSearch.ClientID + "\',\'\')', 0);")
''Dim str As String = TextBox1.ClientID.Replace("_", "
\")
If Not IsPostBack Then
GrdSummery.DataBind()
End If
'BtnSearch_Click(sender, e)
' GrdSummery.Visible = True
End Sub
") If Not IsPostBack Then GrdSummery.DataBind() End If 'BtnSearch_Click(sender, e) ' GrdSummery.Visible = True End Sub
Protected Sub TxtSearch_TextChanged(sender As Object, e As EventArgs) Handles TxtSearch.TextChanged
SearchString = TxtSearch.Text
End Sub
I am getting Error :
Could not find control ’Txtsearch’ in ControlParameter ’companyname’.
Any Help Would be appreciated.
I am getting Error :
Could not find control 'Txtsearch' in ControlParameter 'companyname'.
Any Help Would be appreciated.
Try using
Try using
<asp:ControlParameter Name="companyname" ControlID='<%=Txtsearch.ClientID%>' PropertyName="Text" />
这篇关于如何在文本框中键入时显示gridview的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!