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 プロパティ



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

辞書ショートカット

すべての辞書の索引

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

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

   

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



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

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

©2025 GRAS Group, Inc.RSS