DataBoundControl.PerformDataBinding メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > DataBoundControl.PerformDataBinding メソッドの意味・解説 

DataBoundControl.PerformDataBinding メソッド

メモ : このメソッドは、.NET Framework version 2.0新しく追加されたものです。

派生クラスオーバーライドされると、データ ソースデータコントロールバインドます。

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

Protected Friend Overridable
 Sub PerformDataBinding ( _
    data As IEnumerable _
)
Dim data As IEnumerable

Me.PerformDataBinding(data)
protected internal virtual void PerformDataBinding
 (
    IEnumerable data
)
protected public:
virtual void PerformDataBinding (
    IEnumerable^ data
)
protected void PerformDataBinding (
    IEnumerable data
)
protected internal function
 PerformDataBinding (
    data : IEnumerable
)

パラメータ

data

PerformSelect メソッド呼び出し返されるデータの IEnumerable リスト

解説解説
使用例使用例

DataBoundControl派生クラス内で PerformDataBinding メソッド実装する方法次のコード例示しますTextBoxSet コントロールは、バインド先のデータ項目に対しTextBox コントロール作成します。このコード例は、DataBoundControl クラストピック取り上げているコード例一部分です。

Protected Overrides Sub
 PerformDataBinding(ByVal retrievedData As
 IEnumerable)
    MyBase.PerformDataBinding(retrievedData)

    ' If the data is retrieved from an IDataSource as an IEnumerable
 
    ' collection, attempt to bind its values to a set of TextBox controls.
    If Not (retrievedData Is
 Nothing) Then

        Dim dataItem As Object
        For Each dataItem In
 retrievedData

            Dim box As New
 TextBox()

            ' The dataItem is not just a string, but potentially
            ' a System.Data.DataRowView or some other container. 
            ' If DataTextField is set, use it to determine which 
            ' field to render. Otherwise, use the first field.     
               
            If DataTextField.Length > 0 Then
                box.Text = DataBinder.GetPropertyValue( _
                dataItem, DataTextField, Nothing)
            Else
                Dim props As PropertyDescriptorCollection
 = _
                    TypeDescriptor.GetProperties(dataItem)

                ' Set the "default" value of the TextBox.
                box.Text = String.Empty

                ' Set the true data-bound value of the TextBox,
                ' if possible.
                If props.Count >= 1 Then
                    If props(0).GetValue(dataItem) IsNot Nothing
 Then
                        box.Text = props(0).GetValue(dataItem).ToString()
                    End If
                End If
            End If

            BoxSet.Add(box)
        Next dataItem
    End If

End Sub 'PerformDataBinding

protected override void PerformDataBinding(IEnumerable
 retrievedData) {
    base.PerformDataBinding(retrievedData);

    // If the data is retrieved from an IDataSource as an 
    // IEnumerable collection, attempt to bind its values to a 
    // set of TextBox controls.
    if (retrievedData != null) {

        foreach (object dataItem in retrievedData)
 {
            
            TextBox box = new TextBox();
            
            // The dataItem is not just a string, but potentially
            // a System.Data.DataRowView or some other container. 
            // If DataTextField is set, use it to determine which 
            // field to render. Otherwise, use the first field.    
                
            if (DataTextField.Length > 0) {
                box.Text = DataBinder.GetPropertyValue(dataItem, 
                    DataTextField, null);
            }
            else {
                PropertyDescriptorCollection props = 
                    TypeDescriptor.GetProperties(dataItem);

                // Set the "default" value of the TextBox.
                box.Text = String.Empty;
                
                // Set the true data-bound value of the TextBox,
                // if possible.
                if (props.Count >= 1) {                   
     
                    if (null != props[0].GetValue(dataItem))
 {
                        box.Text = props[0].GetValue(dataItem).ToString();
                    }
                }
            }                                        
            
            BoxSet.Add(box);
        }
    }
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DataBoundControl クラス
DataBoundControl メンバ
System.Web.UI.WebControls 名前空間



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

辞書ショートカット

すべての辞書の索引

「DataBoundControl.PerformDataBinding メソッド」の関連用語

DataBoundControl.PerformDataBinding メソッドのお隣キーワード
検索ランキング

   

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



DataBoundControl.PerformDataBinding メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS