SqlDataSourceView.FilterExpression プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > SqlDataSourceView.FilterExpression プロパティの意味・解説 

SqlDataSourceView.FilterExpression プロパティ

メモ : このプロパティは、.NET Framework version 2.0 で新しく追加されたものです。

Select メソッドの呼び出し時に適用されるフィルタ処理式を取得または設定します。

名前空間: System.Web.UI.WebControls
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public Property FilterExpression As
 String
Dim instance As SqlDataSourceView
Dim value As String

value = instance.FilterExpression

instance.FilterExpression = value
public string FilterExpression { get;
 set; }
public:
property String^ FilterExpression {
    String^ get ();
    void set (String^ value);
}
/** @property */
public String get_FilterExpression ()

/** @property */
public void set_FilterExpression (String value)
public function get FilterExpression
 () : String

public function set FilterExpression
 (value : String)

プロパティ値
Select メソッドを使用してデータを取得するときに適用される、フィルタ処理式を表す文字列。

例外例外
例外の種類条件

NotSupportedException

SqlDataSource が DataReader モードのときに、FilterExpression プロパティが設定されました。

解説解説
使用例使用例

Northwind データベースからデータを取得し、FilterExpression プロパティと FilterParameters プロパティを使用してフィルタ処理する方法を次のコード例に示します。Select メソッドを実行してデータを取得するときは常に、SqlDataSource コントロールの FilterExpression プロパティが適用されます。この例では、FilterExpression プロパティに、FilterParameters コレクションに格納されているフィルタ パラメータのプレースホルダが格納されています。この例では、フィルタ パラメータは、DropDownList コントロールの SelectedValue プロパティにバインドされている ControlParameter オブジェクトです。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>
    <BODY>
        <FORM runat="server">

            <p>Show all employees with the following title:
            <asp:DropDownList
                id="DropDownList1"
                runat="server"
                AutoPostBack="True">
                <asp:ListItem Selected>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>

        </FORM>
    </BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<HTML>
    <BODY>
        <FORM runat="server">

            <p>Show all employees with the following title:
            <asp:DropDownList
                id="DropDownList1"
                runat="server"
                AutoPostBack="True">
                <asp:ListItem Selected>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>

        </FORM>
    </BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<HTML>
    <BODY>
        <FORM runat="server">

            <p>Show all employees with the following title:
            <asp:DropDownList
                id="DropDownList1"
                runat="server"
                AutoPostBack="True">
                <asp:ListItem Selected>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="Data Source=localhost;Integrated Security=SSPI;Initial
 Catalog=Northwind;"
                SelectCommand="SELECT EmployeeID,FirstName,LastName,Title FROM
 Employees"
                FilterExpression="Title='@Title'">
                <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>

        </FORM>
    </BODY>
</HTML>
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
SqlDataSourceView クラス
SqlDataSourceView メンバ
System.Web.UI.WebControls 名前空間
FilterParameters
SqlDataSource.DataSourceMode プロパティ



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「SqlDataSourceView.FilterExpression プロパティ」の関連用語

SqlDataSourceView.FilterExpression プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



SqlDataSourceView.FilterExpression プロパティのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS