asp SqlDataSource 过滤表达式;多个搜索框
我正在尝试对 asp:GridView
中的单列数据执行单个搜索,但是我希望每列上方有多个筛选(搜索)框,以便可以在自己的透视列中进行搜索。理论上可以清楚地解决这个问题的是拥有多个FilterExpressions。我正在使用VB,而且很新,很容易对VB产生误解,请直接说:
PS。当只有一个过滤器(搜索)框时,我已经让它工作没有问题,这目前不执行任何操作
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="xxx"
ProviderName="xxxx"
SelectCommand="SELECT [ddiID], [volusionID], [Customer], [email], [Total], [SumOfTotal] FROM [BBnewsalesQry] ORDER BY [Customer]"
FilterExpression="customer like '%{0}%' OR ddiID like '%{0}%'">
<FilterParameters>
<asp:ControlParameter Name="ddiID" ControlID="ddiIDSearch" PropertyName="Text" />
<asp:ControlParameter Name="customer" ControlID="txtSearch" PropertyName="Text" />
</FilterParameters>
</asp:SqlDataSource>
<div>
<b>DDI Search:</b> <asp:TextBox ID="ddiIDSearch" runat="server" />
<b>Customer Search:</b> <asp:TextBox ID="txtSearch" runat="server" />
<asp:ImageButton ID="btnSearch" ImageUrl="http:xxx" runat="server" />
<asp:ImageButton ID="btnClear" ImageUrl="http:xxx" runat="server" />
</div>
然后在 GridView 内:
<asp:TemplateField HeaderText="ddiID" SortExpression="ddiID">
<ItemStyle HorizontalAlign="Left" />
<ItemTemplate>
<asp:Label ID="lblddiid" Text='<%#HighlightText(Eval("ddiid")) %>'
CssClass="TextField" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="volusionID" HeaderText="volusionID" ReadOnly="True" SortExpression="volusionID" />
<asp:TemplateField HeaderText="customer" SortExpression="customer">
<ItemStyle HorizontalAlign="Left" />
<ItemTemplate>
<asp:Label ID="lblcustomer" Text='<%#HighlightText(Eval("customer")) %>'
CssClass="TextField" runat="server" />
</ItemTemplate>
</asp:TemplateField>
I am trying to perform a single search on a single column of data in an asp:GridView
, however I want multiple filter (search) boxes above each column so one could search within its own perspective column. What would clearly fix this theoretically is to have multiple FilterExpressions
. I am using VB and am very new and easily misunderstood with VB, please bare with:
PS. I have gotten it to work no problem when only having ONE filter (search) box, this currently doesn't do anything
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="xxx"
ProviderName="xxxx"
SelectCommand="SELECT [ddiID], [volusionID], [Customer], [email], [Total], [SumOfTotal] FROM [BBnewsalesQry] ORDER BY [Customer]"
FilterExpression="customer like '%{0}%' OR ddiID like '%{0}%'">
<FilterParameters>
<asp:ControlParameter Name="ddiID" ControlID="ddiIDSearch" PropertyName="Text" />
<asp:ControlParameter Name="customer" ControlID="txtSearch" PropertyName="Text" />
</FilterParameters>
</asp:SqlDataSource>
<div>
<b>DDI Search:</b> <asp:TextBox ID="ddiIDSearch" runat="server" />
<b>Customer Search:</b> <asp:TextBox ID="txtSearch" runat="server" />
<asp:ImageButton ID="btnSearch" ImageUrl="http:xxx" runat="server" />
<asp:ImageButton ID="btnClear" ImageUrl="http:xxx" runat="server" />
</div>
Then inside the GridView:
<asp:TemplateField HeaderText="ddiID" SortExpression="ddiID">
<ItemStyle HorizontalAlign="Left" />
<ItemTemplate>
<asp:Label ID="lblddiid" Text='<%#HighlightText(Eval("ddiid")) %>'
CssClass="TextField" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="volusionID" HeaderText="volusionID" ReadOnly="True" SortExpression="volusionID" />
<asp:TemplateField HeaderText="customer" SortExpression="customer">
<ItemStyle HorizontalAlign="Left" />
<ItemTemplate>
<asp:Label ID="lblcustomer" Text='<%#HighlightText(Eval("customer")) %>'
CssClass="TextField" runat="server" />
</ItemTemplate>
</asp:TemplateField>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您两次引用相同的参数 - 请尝试以下操作:
you are referencing the same parameter twice - try the following:
我已经解决了在“Where”语句中创建两个或多个“Like 子句”的问题,使用:
I have resolved the problem of create two or more "Like clause" in the "Where" statement using: