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

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

SqlDataSource.FilterExpression プロパティ

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

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

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

Public Property FilterExpression As
 String
Dim instance As SqlDataSource
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

FilterExpression プロパティ設定されており、SqlDataSource が DataReader モードです。

解説解説

FilterExpression プロパティ使用する構文は、書式指定文字列スタイルの式です。フィルタ式は、Select メソッド実行によって返される DataView オブジェクトの RowFilter プロパティ適用されるため、フィルタ式の構文は、RowFilter プロパティ受け入れられる構文と同じです。詳細については、「Expression」を参照してください

パラメータを FilterParameters コレクション追加する場合パラメータ値を置換する式に書式指定文字列プレースホルダ (たとえば、"{0}")含めることもできます。このプレースホルダは、FilterParameters コレクション内のパラメータインデックスに従って置き換えられます。

FilterExpression プロパティには、パラメータ使用できますパラメータ文字列型または文字型の場合パラメータ単一引用符囲みますパラメータ数値型場合引用符不要です。FilterParameters コレクションは、FilterExpression プロパティ見つかったプレースホルダについて評価されるパラメータ格納します

SqlDataSource コントロールデータフィルタ処理サポートするのは、DataSet モード場合だけです。

FilterExpression プロパティは、SqlDataSource コントロール関連付けられた SqlDataSourceView オブジェクトの FilterExpression プロパティに処理を代行させます

使用例使用例

Northwind データベースからデータ取得しFilterExpression 文字列FilterParameters コレクション使用してフィルタ処理する方法次のコード例示しますSelect メソッド実行してデータ取得するときは常に、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>
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
SqlDataSource クラス
SqlDataSource メンバ
System.Web.UI.WebControls 名前空間
FilterParameters
SqlDataSource.DataSourceMode プロパティ


このページでは「.NET Framework クラス ライブラリ リファレンス」からSqlDataSource.FilterExpression プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からSqlDataSource.FilterExpression プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からSqlDataSource.FilterExpression プロパティ を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

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

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

   

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



SqlDataSource.FilterExpression プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS