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

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

FormView.InsertItemTemplate プロパティ

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

挿入モードの項目用のカスタム コンテンツ取得または設定します

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

<TemplateContainerAttribute(GetType(FormView), BindingDirection.TwoWay)>
 _
Public Overridable Property
 InsertItemTemplate As ITemplate
Dim instance As FormView
Dim value As ITemplate

value = instance.InsertItemTemplate

instance.InsertItemTemplate = value
[TemplateContainerAttribute(typeof(FormView), BindingDirection.TwoWay)] 
public virtual ITemplate InsertItemTemplate { get;
 set; }
[TemplateContainerAttribute(typeof(FormView), BindingDirection::TwoWay)] 
public:
virtual property ITemplate^ InsertItemTemplate {
    ITemplate^ get ();
    void set (ITemplate^ value);
}
/** @property */
public ITemplate get_InsertItemTemplate ()

/** @property */
public void set_InsertItemTemplate (ITemplate
 value)
public function get InsertItemTemplate
 () : ITemplate

public function set InsertItemTemplate
 (value : ITemplate)

プロパティ
FormView コントロール挿入モード場合データ行のカスタム コンテンツを含む System.Web.UI.ITemplate。既定値null で、このプロパティ設定されていないことを示します

解説解説

FormView コントロールは、コントロールの (CurrentMode プロパティ指定された) 現在のモード基づいて異なテンプレートデータ行に表示します各モードで使用されるテンプレート次の表に示します

モード

表示されるテンプレート

Edit

EditItemTemplate

Insert

InsertItemTemplate

Read-only

ItemTemplate

InsertItemTemplate プロパティ使用してFormView コントロール挿入モード場合データ行に独自のユーザー インターフェイス (UI) を定義します通常、項目挿入テンプレートには、ユーザー新規レコードの値を入力するための入力コントロールと、レコード挿入したり、挿入操作キャンセルしたりするためのコマンド ボタン含まれます。

カスタム テンプレート指定するには、最初にFormView コントロール開始タグ終了タグの間に <InsertItemTemplate> タグ配置しますその後<InsertItemTemplate>開始タグ終了タグの間に、テンプレート内容リスト記述できます双方向のバインド式を使用すると、フィールド入力コントロール関連付けることができますレコード挿入されると、FormView コントロールは、自動的に関連付けられた入力コントロールか更新されフィールド値を抽出します。双方向のバインド式の詳細については、「データベースへのバインド」を参照してください組み込みキャンセル操作挿入操作実行するコマンド ボタン作成するには、CommandName プロパティ次の表の値のいずれかに設定してコマンド ボタン コントロールテンプレート追加します

項目テンプレート外観は、InsertRowStyle プロパティ使用して制御できます

使用例使用例

挿入モードデータ行にカスタム テンプレート定義する方法次の例に示します

<%@ Page language="VB" %>

<html>
  <body>
    <form runat="server">
        
      <h3>FormView InsertItemTemplate Example</h3>
                       
      <asp:formview id="EmployeeFormView"
        datasourceid="EmployeeSource"
        allowpaging="true"
        datakeynames="EmployeeID"
        emptydatatext="No employees found."  
        runat="server">
        
        <rowstyle backcolor="LightGreen"
          wrap="false"/>
        <insertrowstyle backcolor="LightBlue"
          wrap="false"/>

        <itemtemplate>
          <table>
            <tr>
              <td rowspan="5">
                <asp:image id="CompanyLogoImage"
                  imageurl="~/Images/Logo.jpg"
                  alternatetext="Company Logo"
                  runat="server"/>
              </td>
              <td colspan="2">
                  &nbsp; 
              </td>
            </tr>
            <tr>
              <td>
                <b>Name:</b>
              </td>
              <td>
                <%# Eval("FirstName") %> <%#
 Eval("LastName") %>
              </td>
            </tr>
            <tr>
              <td>
                <b>Title:</b>
              </td>
              <td>
                <%# Eval("Title") %>
              </td>
            </tr>
            <tr>
              <td colspan="2">
                <asp:linkbutton id="NewButton"
                  text="New"
                  commandname="New"
                  runat="server"/> 
              </td>
            </tr>
          </table>       
        </itemtemplate>
        <insertitemtemplate>
          <table>
            <tr>
              <td rowspan="4">
                <asp:image id="CompanyLogoEditImage"
                  imageurl="~/Images/Logo.jpg"
                  alternatetext="Company Logo"
                  runat="server"/>
              </td>
              <td colspan="2">
                  &nbsp; 
              </td>
            </tr>
            <tr>
              <td>
                <b>Name:</b>
              </td>
              <td>
                <asp:textbox id="FirstNameInsertTextBox"
                  text='<%# Bind("FirstName") %>'
                  runat="server"/>
                <asp:textbox id="LastNameInsertTextBox"
                  text='<%# Bind("LastName") %>'
                  runat="server"/>
              </td>
            </tr>
            <tr>
              <td>
                <b>Title:</b>
              </td>
              <td>
                <asp:textbox id="TitleInsertTextBox"
                  text='<%# Bind("Title") %>'
                  runat="server"/> 
              </td>
            </tr>
            <tr>
              <td colspan="2">
                <asp:linkbutton id="InsertButton"
                  text="Insert"
                  commandname="Insert"
                  runat="server"/>
                <asp:linkbutton id="CancelButton"
                  text="Cancel"
                  commandname="Cancel"
                  runat="server"/> 
              </td>
            </tr>
          </table>       
        </insertitemtemplate> 
                  
      </asp:formview>

      <!-- This example uses Microsoft SQL Server and connects
  -->
      <!-- to the Northwind sample database. Use an ASP.NET
     -->
      <!-- expression to retrieve the connection string
 value   -->
      <!-- from the Web.config file.                            -->
      <asp:sqldatasource id="EmployeeSource"
        selectcommand="Select [EmployeeID], [LastName], [FirstName],
 [Title], [PhotoPath] From [Employees]"
        insertcommand="Insert Into [Employees] ([LastName], [FirstName],
 [Title]) VALUES (@LastName, @FirstName, @Title)"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
 
        runat="server"/>
            
    </form>
  </body>
</html>

<%@ Page language="C#" %>

<html>
  <body>
    <form runat="server">
        
      <h3>FormView InsertItemTemplate Example</h3>
                       
      <asp:formview id="EmployeeFormView"
        datasourceid="EmployeeSource"
        allowpaging="true"
        datakeynames="EmployeeID"
        emptydatatext="No employees found."  
        runat="server">
        
        <rowstyle backcolor="LightGreen"
          wrap="false"/>
        <insertrowstyle backcolor="LightBlue"
          wrap="false"/>

        <itemtemplate>
          <table>
            <tr>
              <td rowspan="5">
                <asp:image id="CompanyLogoImage"
                  imageurl="~/Images/Logo.jpg"
                  alternatetext="Company Logo"
                  runat="server"/>
              </td>
              <td colspan="2">
                  &nbsp; 
              </td>
            </tr>
            <tr>
              <td>
                <b>Name:</b>
              </td>
              <td>
                <%# Eval("FirstName") %> <%# Eval("LastName")
 %>
              </td>
            </tr>
            <tr>
              <td>
                <b>Title:</b>
              </td>
              <td>
                <%# Eval("Title") %>
              </td>
            </tr>
            <tr>
              <td colspan="2">
                <asp:linkbutton id="NewButton"
                  text="New"
                  commandname="New"
                  runat="server"/> 
              </td>
            </tr>
          </table>       
        </itemtemplate>
        <insertitemtemplate>
          <table>
            <tr>
              <td rowspan="4">
                <asp:image id="CompanyLogoEditImage"
                  imageurl="~/Images/Logo.jpg"
                  alternatetext="Company Logo"
                  runat="server"/>
              </td>
              <td colspan="2">
                  &nbsp; 
              </td>
            </tr>
            <tr>
              <td>
                <b>Name:</b>
              </td>
              <td>
                <asp:textbox id="FirstNameInsertTextBox"
                  text='<%# Bind("FirstName") %>'
                  runat="server"/>
                <asp:textbox id="LastNameInsertTextBox"
                  text='<%# Bind("LastName") %>'
                  runat="server"/>
              </td>
            </tr>
            <tr>
              <td>
                <b>Title:</b>
              </td>
              <td>
                <asp:textbox id="TitleInsertTextBox"
                  text='<%# Bind("Title") %>'
                  runat="server"/> 
              </td>
            </tr>
            <tr>
              <td colspan="2">
                <asp:linkbutton id="InsertButton"
                  text="Insert"
                  commandname="Insert"
                  runat="server"/>
                <asp:linkbutton id="CancelButton"
                  text="Cancel"
                  commandname="Cancel"
                  runat="server"/> 
              </td>
            </tr>
          </table>       
        </insertitemtemplate> 
                  
      </asp:formview>

      <!-- This example uses Microsoft SQL Server and connects  -->
      <!-- to the Northwind sample database. Use an ASP.NET     -->
      <!-- expression to retrieve the connection string value
   -->
      <!-- from the Web.config file.                            -->
      <asp:sqldatasource id="EmployeeSource"
        selectcommand="Select [EmployeeID], [LastName], [FirstName], [Title],
 [PhotoPath] From [Employees]"
        insertcommand="Insert Into [Employees] ([LastName], [FirstName], [Title])
 VALUES (@LastName, @FirstName, @Title)"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
 
        runat="server"/>
            
    </form>
  </body>
</html>

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
FormView クラス
FormView メンバ
System.Web.UI.WebControls 名前空間
System.Web.UI.ITemplate
InsertRowStyle
FormView.EditItemTemplate プロパティ
FormView.EmptyDataTemplate プロパティ
FormView.FooterTemplate プロパティ
FormView.HeaderTemplate プロパティ
ItemTemplate
PagerTemplate
ItemInserted
ItemInserting



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

辞書ショートカット

すべての辞書の索引

「FormView.InsertItemTemplate プロパティ」の関連用語

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

   

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



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

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

©2025 GRAS Group, Inc.RSS