SqlDataSource.FilterParameters プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
FilterExpression 文字列のパラメーター プレースホルダーに関連付けられたパラメーターのコレクションを取得します。
public:
property System::Web::UI::WebControls::ParameterCollection ^ FilterParameters { System::Web::UI::WebControls::ParameterCollection ^ get(); };
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
public System.Web.UI.WebControls.ParameterCollection FilterParameters { get; }
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
member this.FilterParameters : System.Web.UI.WebControls.ParameterCollection
Public ReadOnly Property FilterParameters As ParameterCollection
プロパティ値
ParameterCollection プロパティに含まれる任意のパラメーター プレースホルダーに関連付けられたパラメーターのセットを格納している FilterExpression。
- 属性
例
次のコード例では、Northwind データベースからデータを取得し、 プロパティと FilterParameters プロパティを使用してフィルター処理する方法をFilterExpression示します。 コントロールの SqlDataSource プロパティはFilterExpression、メソッドを実行してデータをSelect取得するたびに適用されます。 この例では、 プロパティには FilterExpression 、コレクションに含まれるフィルター パラメーターのプレースホルダーが FilterParameters 含まれています。 さらに、filter パラメーターは、 ControlParameter コントロールの DropDownList プロパティにSelectedValueバインドされるオブジェクトです。 コントロールの DropDownList プロパティが AutoPostBack に true
設定されているため、選択範囲を DropDownList 変更すると、ページはサーバーに情報をポストバックし、コントロールは GridView 新しいフィルターを使用してデータ ソース コントロールに再バインドされます。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>ASP.NET Example</title>
</head>
<body>
<form id="form1" runat="server">
<p>Show all employees with the following title:
<asp:DropDownList
id="DropDownList1"
runat="server"
AutoPostBack="True">
<asp:ListItem Selected="True">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:MyNorthwind%>"
SelectCommand="SELECT EmployeeID,FirstName,LastName,Title FROM Employees"
FilterExpression="Title='{0}'">
<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></p>
</form>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>ASP.NET Example</title>
</head>
<body>
<form id="form1" runat="server">
<p>Show all employees with the following title:
<asp:DropDownList
id="DropDownList1"
runat="server"
AutoPostBack="True">
<asp:ListItem Selected="True">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:MyNorthwind%>"
SelectCommand="SELECT EmployeeID,FirstName,LastName,Title FROM Employees"
FilterExpression="Title='{0}'">
<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></p>
</form>
</body>
</html>
注釈
コレクション内の FilterParameters パラメーターは、 プロパティで指定されたすべてのパラメーターに FilterExpression 関連付けられます。 プロパティでFilterExpression指定されたパラメーター プレースホルダーは、 メソッドの呼び出し時Selectにコレクション内のFilterParametersパラメーター オブジェクトの順序で照合されます。
プロパティは FilterParameters 、コントロールに FilterParameters 関連付けられている オブジェクトに SqlDataSourceView 含まれるプロパティを SqlDataSource 取得します。
重要
値は検証なしでパラメーターに挿入されます。これは、潜在的なセキュリティ上の脅威です。 イベントを Filtering 使用して、クエリを実行する前にパラメーター値を検証します。 詳細については、「スクリプトによる攻略の概要」を参照してください。
適用対象
こちらもご覧ください
.NET
フィードバック
https://aka.ms/ContentUserFeedback」を参照してください。
以下は間もなく提供いたします。2024 年を通じて、コンテンツのフィードバック メカニズムとして GitHub の issue を段階的に廃止し、新しいフィードバック システムに置き換えます。 詳細については、「フィードバックの送信と表示