下午所有,
我有一个网格视图,用于显示数据库中的“操作”列表。
我有一个连接到此网格视图的下拉列表,这使用户能够通过下拉列表中的“操作状态”(“已分配”、“进行中”和“已完成”)过滤数据。这工作得很好....
我想要做的是为用户提供另一个过滤器选项,他们也想按用户名过滤。我为此设置了数据源和下拉列表,但我只能将一个数据源连接到我的gridview?
有没有人建议如何让用户也可以按用户名和“操作状态”进行过滤?
如果您需要看一下,这是我的代码....
<asp:SqlDataSource ID="dsActions" runat="server"
ConnectionString="<%$ ConnectionStrings:SMCConnectionString %>"
SelectCommand="Populate_grdAllActions_Filter"
SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:ControlParameter ControlID="ddFilterStatus" Name="ActionStatusID"
PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="dsActionsByUser" runat="server"
ConnectionString="<%$ ConnectionStrings:SMCConnectionString %>"
SelectCommand="Populate_grdAllActions_Filter_By_User"
SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:ControlParameter ControlID="ddFilterUsers" Name="UserID"
PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="dsFilterList" runat="server"
ConnectionString="<%$ ConnectionStrings:SMCConnectionString %>"
SelectCommand="SELECT * FROM [ActionStatus]"></asp:SqlDataSource>
<asp:SqlDataSource ID="dsFilterUsers" runat="server"
ConnectionString="<%$ ConnectionStrings:SMCConnectionString %>"
SelectCommand="SELECT * FROM [UserSimpleList]"></asp:SqlDataSource>
<table style="width: 400px">
<tr>
<td colspan="2" style="height: 25px"><b>Filter Options:</b></td>
</tr>
<tr>
<td style="width: 158px">
Select Action Status:</td>
<td>
<asp:DropDownList ID="ddFilterStatus" runat="server"
DataTextField="ActionStatus" DataValueField="ActionStatusID"
AutoPostBack="True" DataSourceID="dsFilterList"></asp:DropDownList>
</td>
</tr>
<tr>
<td style="width: 158px">
Select Actions by User:</td>
<td>
<asp:DropDownList ID="ddFilterUsers" runat="server"
DataTextField="UserFullName" DataValueField="UserID"
AutoPostBack="True" DataSourceID="dsFilterUsers"></asp:DropDownList></td>
</tr>
</table>
<br/>
<asp:GridView ID="grdActions" runat="server" AutoGenerateColumns="False"
DataSourceID="dsActions" CssClass="mGrid"
PagerStyle-CssClass="pgr" AlternatingRowStyle-CssClass="alt"
AllowPaging="True" PageSize="6" DataKeyNames="ActionID" Width="68%" >
<AlternatingRowStyle CssClass="alt" />
<Columns>
<asp:HyperLinkField DataNavigateUrlFields="ActionID" DataNavigateUrlFormatString="~/UpdateAction.aspx?Edit={0}"
DataTextField="ActionID" HeaderText="Action ID" >
<HeaderStyle HorizontalAlign="Center" Wrap="True" />
<ItemStyle HorizontalAlign="Center" />
</asp:HyperLinkField>
<asp:BoundField DataField="Action" HeaderText="Action"
SortExpression="Action" >
<HeaderStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="Owner" HeaderText="Owner"
SortExpression="Owner">
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="TargetDate" HeaderText="Target Date"
SortExpression="TargetDate" DataFormatString="{0:dd-MM-yyyy} " >
<HeaderStyle HorizontalAlign="Center" Wrap="True" />
<ItemStyle Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="Action Status" HeaderText="Action Status"
SortExpression="Action Status" >
<HeaderStyle HorizontalAlign="Center" Wrap="True" />
<ItemStyle Wrap="False" />
</asp:BoundField>
</Columns>
<PagerStyle CssClass="pgr" />
</asp:GridView>
任何帮助都是提前得到的。
问候贝蒂