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

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

HtmlSelect.DataMember プロパティ

複数データ セットを持つ DataSource プロパティから HtmlSelect コントロールバインドするデータ セット取得または設定します

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

Public Overridable Property
 DataMember As String
Dim instance As HtmlSelect
Dim value As String

value = instance.DataMember

instance.DataMember = value
public virtual string DataMember { get;
 set; }
/** @property */
public String get_DataMember ()

/** @property */
public void set_DataMember (String value)

プロパティ
複数データ セットを持つ DataSource から HtmlSelect コントロールバインドするデータ セット既定値空の文字列 ("") です。このプロパティ設定されていないことを示します

解説解説
使用例使用例

DataMember プロパティ使用して複数データ セットを持つ DataSource プロパティから HtmlSelect コントロールバインドするデータ セット指定する方法次のコード例示します

<%@ Page Language="VB" AutoEventWireup="True"
 %>
<%@ Import Namespace="System.Data"
 %>

<html>

<head>

   <script runat="server">

      Sub Page_Load (sender As Object,
 e As EventArgs)

         ' Bind the HtmlSelect control to a data source when the page
 is initially loaded.
         If Not IsPostBack Then
 
            Dim i As Integer
      
            ' Create a data set to store the tables.
            Dim ds As DataSet = New
 DataSet("TitleDataSet")
            Dim dr As DataRow 

            ' Create the authors table with a single column.
            Dim authors As DataTable = New
 DataTable("Authors")            
            authors.Columns.Add(New DataColumn("LName",
 GetType(String)))                    
 
            ' Add the authors table to the data set.
            ds.Tables.Add(authors)

            ' Create sample data in the authors table.
            For i = 0 To 9 
           
               ' Create a new row for the authors table.
               dr = authors.NewRow()

               ' Add data to the LName column (column 0 in the row).
               dr(0) = "Author " & i.ToString()

               ' Insert the row into the authors table.   
               authors.Rows.Add(dr)

            Next i
  
            ' Create the titles table with a single column.
            Dim titles As DataTable = New
 DataTable("Titles")            
            titles.Columns.Add(New DataColumn("BookTitle",
 GetType(String)))                    
 
            ' Add the titles table to the data set.
            ds.Tables.Add(titles)

            ' Create sample data in the titles table.
            For i = 0 To 9
            
               ' Create a new row for the titles table.
               dr = titles.NewRow()

               ' Add data to the BookTitle column (column 0 in the row).
               dr(0) = "Title " & i.ToString()

               ' Insert the row into the titles table.   
               titles.Rows.Add(dr)

            Next i

            ' Bind the HtmlSelect control to the data source.
            Select1.DataSource = ds
            Select1.DataMember = "Titles"
            Select1.DataTextField = "BookTitle"
            Select1.DataBind()

         End If

      End Sub

      Sub Button_Click (sender As Object,
 e As EventArgs)

         Dim i As Integer
       
         ' Display the selected items. 
         Label1.Text = "You selected:"

         For i=0 To Select1.Items.Count - 1
      
            If Select1.Items(i).Selected Then
               Label1.Text = Label1.Text & "<br> &nbsp;&nbsp;
 - " & Select1.Items(i).Text
            End If
         
         Next i

      End Sub

   </script>

</head>

<body>

   <form runat="server">

      <h3> HtmlSelect Example </h3>

      Select items from the list. <br>
      Use the Control or Shift key to select
 multiple items. <br><br>

      <select id="Select1"
              Multiple="True" 
              runat="server"/>

      <br><br>

      <button id="Button1"
              OnServerClick="Button_Click"
              runat="server">

         Submit

      </button>

      <br><br>

      <asp:Label id="Label1"
           runat="server"/>

   </form>

</body>

</html>
<%@ Page Language="C#" AutoEventWireup="True" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>

<html>

<head>

   <script runat="server">

      void Page_Load (Object sender, EventArgs e)
      {

         // Bind the HtmlSelect control to a data source when the page
 is initially loaded.
         if (!IsPostBack)
         {
      
            // Create a data set to store the tables.
            DataSet ds = new DataSet("TitleDataSet");
            DataRow dr; 

            // Create the authors table with a single column.
            DataTable authors = new DataTable("Authors");
            
            authors.Columns.Add(new DataColumn("LName",
 typeof(string)));                    
 
            // Add the authors table to the data set.
            ds.Tables.Add(authors);

            // Create sample data in the authors table.
            for (int i = 0; i < 9; i++)
 
            {
               // Create a new row for the authors table.
               dr = authors.NewRow();

               // Add data to the LName column (column 0 in the row).
               dr[0] = "Author " + i.ToString();

               // Insert the row into the authors table.   
               authors.Rows.Add(dr);
            }
  
            // Create the titles table with a single column.
            DataTable titles = new DataTable("Titles");
            
            titles.Columns.Add(new DataColumn("BookTitle",
 typeof(string)));                    
 
            // Add the titles table to the data set.
            ds.Tables.Add(titles);

            // Create sample data in the titles table.
            for (int i = 0; i < 9; i++)
 
            {
               // Create a new row for the titles table.
               dr = titles.NewRow();

               // Add data to the BookTitle column (column 0 in the
 row).
               dr[0] = "Title " + i.ToString();

              // Insert the row into the titles table.   
              titles.Rows.Add(dr);
            }

            // Bind the HtmlSelect control to the data source.
            Select1.DataSource = ds;
            Select1.DataMember = "Titles";
            Select1.DataTextField = "BookTitle";
            Select1.DataBind();

         }

      }

      void Button_Click (Object sender, EventArgs e)
      {
       
         // Display the selected items. 
         Label1.Text = "You selected:";

         for (int i=0; i<=Select1.Items.Count
 - 1; i++)
         {
            if (Select1.Items[i].Selected)
               Label1.Text += "<br> &nbsp;&nbsp; - " + Select1.Items[i].Text;
         }

      }

   </script>

</head>

<body>

   <form runat="server">

      <h3> HtmlSelect Example </h3>

      Select items from the list. <br>
      Use the Control or Shift key to select multiple items. <br><br>

      <select id="Select1"
              Multiple="True" 
              runat="server"/>

      <br><br>

      <button id="Button1"
              OnServerClick="Button_Click"
              runat="server">

         Submit

      </button>

      <br><br>

      <asp:Label id="Label1"
           runat="server"/>

   </form>

</body>

</html>
<%@ Page Language="JScript" AutoEventWireup="True" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>

<html>

<head>

   <script runat="server">

      function Page_Load (sender : Object, e : EventArgs)
      {

         // Bind the HtmlSelect control to a data source when the page
 is initially loaded.
         if (!IsPostBack)
         {
      
            // Create a data set to store the tables.
            var ds : DataSet = new DataSet("TitleDataSet");
            var dr : DataRow; 

            // Create the authors table with a single column.
            var authors : DataTable = new DataTable("Authors");
            
            authors.Columns.Add(new DataColumn("LName",
 GetType("String")));                    
 
            // Add the authors table to the data set.
            ds.Tables.Add(authors);

            // Create sample data in the authors table.
            for (var i : int
 = 0; i < 9; i++) 
            {
               // Create a new row for the authors table.
               dr = authors.NewRow();

               // Add data to the LName column (column 0 in the row).
               dr[0] = "Author " + i.ToString();

               // Insert the row into the authors table.   
               authors.Rows.Add(dr);
            }
  
            // Create the titles table with a single column.
            var titles : DataTable = new DataTable("Titles");
            
            titles.Columns.Add(new DataColumn("BookTitle",
 GetType("String")));                    
 
            // Add the titles table to the data set.
            ds.Tables.Add(titles);

            // Create sample data in the titles table.
            for (var j : int
 = 0; j < 9; j++) 
            {
               // Create a new row for the titles table.
               dr = titles.NewRow();

               // Add data to the BookTitle column (column 0 in the
 row).
               dr[0] = "Title " + j.ToString();

              // Insert the row into the titles table.   
              titles.Rows.Add(dr);
            }

            // Bind the HtmlSelect control to the data source.
            Select1.DataSource = ds;
            Select1.DataMember = "Titles";
            Select1.DataTextField = "BookTitle";
            Select1.DataBind();

         }

      }

      function Button_Click (sender : Object, e : EventArgs)
      {
       
         // Display the selected items. 
         Label1.Text = "You selected:";

         for (var i : int
 = 0; i <= Select1.Items.Count - 1; i++)
         {
            if (Select1.Items[i].Selected)
               Label1.Text += "<br> &nbsp;&nbsp; - " + Select1.Items[i].Text;
         }

      }

   </script>

</head>

<body>

   <form runat="server">

      <h3> HtmlSelect Example </h3>

      Select items from the list. <br>
      Use the Control or Shift key to select multiple items. <br><br>

      <select id="Select1"
              Multiple="True" 
              runat="server"/>

      <br><br>

      <button id="Button1"
              OnServerClick="Button_Click"
              runat="server">

         Submit

      </button>

      <br><br>

      <asp:Label id="Label1"
           runat="server"/>

   </form>

</body>

</html>
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
HtmlSelect クラス
HtmlSelect メンバ
System.Web.UI.HtmlControls 名前空間
DataSource
DataTextField
DataValueField
ListItem.Text
ListItem.Value
その他の技術情報
HTML サーバー コントロール



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

辞書ショートカット

すべての辞書の索引

「HtmlSelect.DataMember プロパティ」の関連用語

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

   

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



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

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

©2024 GRAS Group, Inc.RSS