帮助:使用filterfilterexpression过滤gridview [英] Help : filter gridview using filterfilterexpression
问题描述
我想使用Multi DropdownList过滤Gridview
所以我使用Filter Expresssion
我想在DropList中添加名为Blank的项目to 隐藏值为0的行并仅显示具有值的行(对于此列)
和项目称为 全部查看所有行(对于列)
(与Excel过滤器一样)
有我的代码
I wanted to filter Gridview using Multi DropdownList
So I used Filter Expresssion
I want to add item to DropList called "Blank " to hide rows which have values = 0 and display only rows which have values (For this column )
and Item Called "ALL" to View All rows (For the column )
(Like Excel Filter )
There is my code
<asp:DropDownList ID="Ddl_LastBlnc" runat="server" AutoPostBack="True" DataSourceID="LastBlnc" DataTextField="LastBalance" DataValueField="LastBalance" AppendDataBoundItems="True">
<asp:ListItem Selected="True" Value="" Text="All"></asp:ListItem>
<asp:SqlDataSource ID="LastBlnc" runat="server" ConnectionString="<%$ ConnectionStrings:HHCon %>"
SelectCommand="SELECT DISTINCT LastBalance From Balance" OnSelecting="LastBlnc_Selecting"></asp:SqlDataSource>
<asp:DropDownList ID="Ddl_CurntBlnc" runat="server" AutoPostBack="True" DataSourceID="CrntBlnc" DataTextField="CurrentBalance" DataValueField="CurrentBalance" AppendDataBoundItems="True">
<asp:ListItem Selected="True" Value="" Text="All"></asp:ListItem>
</asp:DropDownList>
<asp:SqlDataSource ID="CrntBlnc" runat="server" ConnectionString="<%$ ConnectionStrings:HHCon %>"
SelectCommand="SELECT DISTINCT CurrentBalance From Balance" OnSelecting="CrntBlnc_Selecting"></asp:SqlDataSource>
// Data source Of GridView
<asp:SqlDataSource ID="SqlDataAll" runat="server" ConnectionString="<%$ ConnectionStrings:HHCon %>"
SelectCommand="SELECT [Code], [CurrentBalance], [LastBalance] From Balance "
FilterExpression="[LastBalance]={0} AND [CurrentBalance] = {1} ">
<FilterParameters>
<asp:ControlParameter ControlID="Ddl_LastBlnc" Name="LastBalance"
PropertyName="SelectedValue" Type="String" />
<asp:ControlParameter ControlID="Ddl_CurntBlnc" Name="CurrentBalance"
PropertyName="SelectedValue" Type="String" />
</FilterParameters>
</asp:SqlDataSource>
我尝试过:
我试图添加这个项目像DroplList中的All项目
但我不知道过滤器表达式将如何!!
What I have tried:
I tried to add this item Like "All" item in DroplList
But I dont know the filter Expression how it will be !!
推荐答案
ConnectionStrings:HHCon %>
SelectCommand = SELECT DISTINCT来自余额的LastBalance OnSelecting = LastBlnc_Selecting > < / asp:SqlDataSource >
ConnectionStrings:HHCon %>" SelectCommand="SELECT DISTINCT LastBalance From Balance" OnSelecting="LastBlnc_Selecting"></asp:SqlDataSource>
<asp:DropDownList ID="Ddl_CurntBlnc" runat="server" AutoPostBack="True" DataSourceID="CrntBlnc" DataTextField="CurrentBalance" DataValueField="CurrentBalance" AppendDataBoundItems="True">
<asp:ListItem Selected="True" Value="" Text="All"></asp:ListItem>
</asp:DropDownList>
<asp:SqlDataSource ID="CrntBlnc" runat="server" ConnectionString="<%
ConnectionStrings:HHCon %>
SelectCommand = SELECT DISTINCT来自余额的CurrentBalance OnSelecting = CrntBlnc_Selecting > < / asp:SqlDataSource >
ConnectionStrings:HHCon %>" SelectCommand="SELECT DISTINCT CurrentBalance From Balance" OnSelecting="CrntBlnc_Selecting"></asp:SqlDataSource>
// Data source Of GridView
<asp:SqlDataSource ID="SqlDataAll" runat="server" ConnectionString="<%
ConnectionStrings:HHCon%>
SelectCommand =SELECT [Code],[CurrentBalance],[LastBalance] From Balance
FilterExpression =[LastBalance] = {0} AND [CurrentBalance] = {1}>
< FilterParameters>
< asp:ControlParameter ControlID =Ddl_LastBlncName =LastBalance
PropertyName =SelectedValueType =String/>
< asp:ControlParameter ControlID =Ddl_CurntBlncName =CurrentBalance
PropertyName =SelectedValueType =String/>
< / FilterParameters>
< / asp:SqlDataSource>
ConnectionStrings:HHCon %>" SelectCommand="SELECT [Code], [CurrentBalance], [LastBalance] From Balance " FilterExpression="[LastBalance]={0} AND [CurrentBalance] = {1} "> <FilterParameters> <asp:ControlParameter ControlID="Ddl_LastBlnc" Name="LastBalance" PropertyName="SelectedValue" Type="String" /> <asp:ControlParameter ControlID="Ddl_CurntBlnc" Name="CurrentBalance" PropertyName="SelectedValue" Type="String" /> </FilterParameters> </asp:SqlDataSource>
我尝试过:
我试图添加这个项目像DroplList中的All项目
但我不知道过滤器Expression它将如何!!
What I have tried:
I tried to add this item Like "All" item in DroplList
But I dont know the filter Expression how it will be !!
这篇关于帮助:使用filterfilterexpression过滤gridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!