Repeater.DataSource プロパティとは何? わかりやすく解説 Weblio辞書

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

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

Repeater.DataSource プロパティ

リスト読み込むデータ提供するデータ ソース取得または設定します

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

<BindableAttribute(True)> _
Public Overridable Property
 DataSource As Object
Dim instance As Repeater
Dim value As Object

value = instance.DataSource

instance.DataSource = value
[BindableAttribute(true)] 
public virtual Object DataSource { get; set;
 }
[BindableAttribute(true)] 
public:
virtual property Object^ DataSource {
    Object^ get ();
    void set (Object^ value);
}
/** @property */
public Object get_DataSource ()

/** @property */
public void set_DataSource (Object value)

プロパティ
このコントロールデータ提供するために使用する値のコレクション格納している IEnumerable オブジェクトまたは IListSource オブジェクト既定値null 参照 (Visual Basic では Nothing) です。

例外例外
例外種類条件

ArgumentException

指定されDataSource オブジェクトが、Repeater コントロールサポートされているデータ ソースではありません。

HttpException

DataSource プロパティと DataSourceID プロパティ両方に値が指定されているため、データ ソース解決できません。

解説解説

このプロパティ使用してRepeater コントロール読み込むデータソース指定しますDataSource としては、データベースアクセスするための System.Data.DataView、System.Collections.ArrayList、System.Collections.Hashtable、配列などの任意の System.Collections.IEnumerable オブジェクト、または IListSource オブジェクト指定できますDataSource プロパティ設定する場合は、データ ソースバインドするコード手動記述する必要があります

DataSource プロパティ指定されているデータ ソース複数データ ソースを含む場合は、DataMember プロパティ使用してコントロールバインドする特定のソース指定します。たとえば複数テーブルを持つ System.Data.DataSet がある場合は、コントロール連結するテーブル指定する必要がありますデータ ソース指定したら、DataBind メソッド使用してデータ ソースコントロール連結します。

また、DataSourceID プロパティ使用してデータ ソース コントロール表されデータ ソースへのバインディング自動的に行うことができますDataSourceID プロパティ設定すると、Repeater コントロールは、指定したデータ ソース コントロール自動的にバインドされますRepeater コントロールプロパティ動的に変更した場合除きDataBind メソッド明示的に呼び出すコード記述する要はありません。

DataSource プロパティDataSourceID プロパティ両方に値を指定した場合ASP.NETデータ ソース解決できず、System.Web.HttpExceptionスローさます。

使用例使用例

ページ読み込み時にRepeater コントロールDataSource指定する方法の例を次に示します

<%@ Page Language="VB" AutoEventWireup="True"
 %>
<html>
 <head>
    <script runat="server">

        Sub Page_Load(Sender As Object,
 e As EventArgs)
            
            If Not IsPostBack Then
                Dim values As New
 ArrayList()
                
                values.Add("Apple")
                values.Add("Orange")
                values.Add("Pear")
                values.Add("Banana")
                values.Add("Grape")
                
                ' Set the DataSource of the Repeater. 
                Repeater1.DataSource = values
                Repeater1.DataBind()
            End If
        End Sub
        
    </script>
 
 </head>
 <body>
 
    <h3>Repeater Example</h3>
 
    <form runat=server>
 
       <b>Repeater1:</b>
       <p>
         
       <asp:Repeater id=Repeater1 runat="server">
             
          <HeaderTemplate>
             <table border=1>
          </HeaderTemplate>
 
          <ItemTemplate>
             <tr>
                <td> <%# Container.DataItem %> </td>
             </tr>
          </ItemTemplate>
             
          <FooterTemplate>
             </table>
          </FooterTemplate>
             
       </asp:Repeater>
       <p>
         
    </form>
 </body>
 </html>
 
<%@ Page Language="C#" AutoEventWireup="True" %>
<html>
 <head>
    <script runat="server">
       void Page_Load(Object Sender, EventArgs e) {
 
          if (!IsPostBack) {
             ArrayList values = new ArrayList();
 
             values.Add("Apple");
             values.Add("Orange");
             values.Add("Pear");
             values.Add("Banana");
             values.Add("Grape");
 
             // Set the DataSource of the Repeater. 
             Repeater1.DataSource = values;
             Repeater1.DataBind();
          }
       }
    </script>
 
 </head>
 <body>
 
    <h3>Repeater Example</h3>
 
    <form runat=server>
 
       <b>Repeater1:</b>
       <p>
         
       <asp:Repeater id=Repeater1 runat="server">
             
          <HeaderTemplate>
             <table border=1>
          </HeaderTemplate>
 
          <ItemTemplate>
             <tr>
                <td> <%# Container.DataItem %> </td>
             </tr>
          </ItemTemplate>
             
          <FooterTemplate>
             </table>
          </FooterTemplate>
             
       </asp:Repeater>
       <p>
         
    </form>
 </body>
 </html>
 
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



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

辞書ショートカット

すべての辞書の索引

「Repeater.DataSource プロパティ」の関連用語

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

   

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



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

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

©2024 GRAS Group, Inc.RSS