SqlDataSourceFilteringEventArgs.ParameterValues プロパティ
アセンブリ: System.Web (system.web.dll 内)

Dim instance As SqlDataSourceFilteringEventArgs Dim value As IOrderedDictionary value = instance.ParameterValues
Parameter オブジェクトの IOrderedDictionary。

SqlDataSourceFilteringEventArgs クラスは、データを SqlDataSource の Filtering イベント ハンドラに渡す場合に使用されます。ParameterValues プロパティは、フィルタ操作を実行する前に、フィルタ パラメータ値へのアクセスを提供します。
![]() |
---|
クライアントから受け取ったフィルタ パラメータ値を検証し、無効なパラメータが存在した場合は、選択操作をキャンセルする必要があります。ランタイムは、パラメータ値をフィルタ式に代入し、それを選択メソッドの結果に対して適用するだけです。想定外の値によってフィルタ式が改変され、クライアントに見せるべきでない行まで表示させるような不正が生じる可能性もあります。FilterExpression プロパティをセキュリティ対策として使用して、返される項目数を制限する場合は、フィルタ処理の実行前にパラメータ値を検証する必要があります。 |

Northwind データベースからデータを取得し、FilterExpression と FilterParameters を使用してフィルタ処理する方法を次のコード例に示します。Select メソッドを実行してデータを取得するときは常に、SqlDataSource の FilterExpression が適用されます。この例では、FilterExpression に、FilterParameters コレクションに格納されているフィルタ パラメータのプレースホルダが格納されています。Filtering イベントで、フィルタ パラメータが Label コントロールに表示されます。
<%@ Page Language="VB" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> Protected Sub SqlDataSource1_Filtering(ByVal sender As Object, _ ByVal e As System.Web.UI.WebControls.SqlDataSourceFilteringEventArgs) Label1.Text = e.ParameterValues(0).ToString() End Sub </script> <HTML> <BODY> <FORM runat="server"> <p>Show all employees with the following title: <asp:DropDownList id="DropDownList1" runat="server" AutoPostBack="True"> <asp:ListItem>Sales Representative</asp:ListItem> <asp:ListItem>Sales Manager</asp:ListItem> <asp:ListItem>Vice President, Sales</asp:ListItem> </asp:DropDownList></p> <asp:SqlDataSource id="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnection %>" SelectCommand="SELECT EmployeeID,FirstName,LastName,Title FROM Employees" FilterExpression="Title='{0}'" OnFiltering="SqlDataSource1_Filtering"> <FilterParameters> <asp:ControlParameter Name="Title" ControlId="DropDownList1" PropertyName="SelectedValue"/> </FilterParameters> </asp:SqlDataSource> <p><asp:GridView id="GridView1" runat="server" DataSourceID="SqlDataSource1" AutoGenerateColumns="False"> <columns> <asp:BoundField Visible="False" DataField="EmployeeID" /> <asp:BoundField HeaderText="First Name" DataField="FirstName" /> <asp:BoundField HeaderText="Last Name" DataField="LastName" /> </columns> </asp:GridView> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> </FORM> </BODY> </HTML>
<%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> //Protected Sub SqlDataSource1_Filtering(ByVal sender As Object, _ // ByVal e As System.Web.UI.WebControls.SqlDataSourceFilteringEventArgs) // Label1.Text = e.ParameterValues(0).ToString() //End Sub protected void SqlDataSource1_Filtering(object sender, SqlDataSourceFilteringEventArgs e) { Label1.Text = e.ParameterValues[0].ToString(); } </script> <HTML> <BODY> <FORM id="FORM1" runat="server"> <p>Show all employees with the following title: <asp:DropDownList id="DropDownList1" runat="server" AutoPostBack="True"> <asp:ListItem>Sales Representative</asp:ListItem> <asp:ListItem>Sales Manager</asp:ListItem> <asp:ListItem>Vice President, Sales</asp:ListItem> </asp:DropDownList></p> <asp:SqlDataSource id="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnection %>" SelectCommand="SELECT EmployeeID,FirstName,LastName,Title FROM Employees" FilterExpression="Title='{0}'" OnFiltering="SqlDataSource1_Filtering"> <FilterParameters> <asp:ControlParameter Name="Title" ControlId="DropDownList1" PropertyName="SelectedValue"/> </FilterParameters> </asp:SqlDataSource> <p><asp:GridView id="GridView1" runat="server" DataSourceID="SqlDataSource1" AutoGenerateColumns="False"> <columns> <asp:BoundField Visible="False" DataField="EmployeeID" /> <asp:BoundField HeaderText="First Name" DataField="FirstName" /> <asp:BoundField HeaderText="Last Name" DataField="LastName" /> </columns> </asp:GridView> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> </FORM> </BODY> </HTML>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からSqlDataSourceFilteringEventArgs.ParameterValues プロパティを検索する場合は、下記のリンクをクリックしてください。

- SqlDataSourceFilteringEventArgs.ParameterValues プロパティのページへのリンク