DynamicDataExtensions.FindFieldTemplate(Control, String) 메서드


지정된 컨트롤의 명명 컨테이너에서 지정된 열에 대한 필드 템플릿을 반환합니다.Returns the field template for the specified column in the specified control's naming container.

 static System::Web::UI::Control ^ FindFieldTemplate(System::Web::UI::Control ^ control, System::String ^ columnName);
public static System.Web.UI.Control FindFieldTemplate (this System.Web.UI.Control control, string columnName);
static member FindFieldTemplate : System.Web.UI.Control * string -> System.Web.UI.Control

매개 변수


상위 컨트롤입니다.The containing control.


열 이름입니다.The name of the column.


지정된 컨트롤의 명명 컨테이너에서 지정된 열에 대한 필드 템플릿입니다.The field template for the specified column in the specified control's naming container.


다음 예제에서는 지정된 된 열 이름에 대 한 텍스트 상자 컨트롤을 찾는 방법을 보여 줍니다.The following example shows how to find the text box control for a specified column name. 예제에서는 동적 데이터 페이지 템플릿은 AdventureWorksLT 데이터베이스의 ProductDescription 테이블에 대 한 사용자 지정 표시를 제공 \DynamicData\CustomPages\ProductDescriptions 폴더에 복사 됩니다.In example, the Dynamic Data page templates are copied to the \DynamicData\CustomPages\ProductDescriptions folder to provide a custom display for the ProductDescription table of the AdventureWorksLT database. Insert.aspx 파일 태그를 추가 하려면 변경 되는 OnDataBound 라는 이벤트 처리기 DetailsView1_DataBoundFindDataSourceControl 텍스트 상자 컨트롤을 찾기 위해 호출 됩니다.The Insert.aspx file markup is changed to add an OnDataBound event handler named DetailsView1_DataBound, in which the FindDataSourceControl method is called to find a text box control.

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using System.Web.DynamicData;

public partial class Insert : System.Web.UI.Page {
    protected MetaTable table;

    protected void Page_Init(object sender, EventArgs e) {

    protected void Page_Load(object sender, EventArgs e) {
        table = DetailsDataSource.GetTable();
        Title = table.DisplayName;

    protected void DetailsView1_DataBound(object sender, EventArgs e) {

        var dsc = DetailsView1.FindDataSourceControl() as LinqDataSource;
        if (dsc == null || dsc.EnableInsert != true)

        var mTbl = DetailsView1.FindMetaTable() as MetaTable;
        if (mTbl != null)
            LblMetaTbl.Text = "Column count = " + mTbl.Columns.Count.ToString();

        var fldTmpUsrCtl = DetailsView1.FindFieldTemplate("Description") as FieldTemplateUserControl;
        if (fldTmpUsrCtl != null) {
            var entryFldDescript = fldTmpUsrCtl.DataControl as TextBox;
            entryFldDescript.Text = "(Enter short Description here.)";

        var fldTmpUsrCtl2 = DetailsView1.FindFieldTemplate("ModifiedDate") as FieldTemplateUserControl;
        if (fldTmpUsrCtl2 != null) {
            var entryFldModDate = fldTmpUsrCtl2.DataControl as TextBox;
            entryFldModDate.Text = System.DateTime.Now.Date.ToShortDateString();

    protected void DetailsView1_ItemCommand(object sender, DetailsViewCommandEventArgs e) {
        if (e.CommandName == DataControlCommands.CancelCommandName) {

    protected void DetailsView1_ItemInserted(object sender, DetailsViewInsertedEventArgs e) {
        if (e.Exception == null) {
<%@ Page Language="C#" MasterPageFile="~/Site.master" CodeFile="Insert.aspx.cs" Inherits="Insert" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:DynamicDataManager ID="DynamicDataManager1" runat="server" AutoLoadForeignKeys="true" />

    <h2> DynamicData\CustomPages\ProductDescriptions\Insert.aspx <%= table.DisplayName %></h2>
    <p>   <asp:Label ID="LblMetaTbl" runat="server" Text="Label"></asp:Label>   </p>

    <asp:ScriptManagerProxy runat="server" ID="ScriptManagerProxy1" />

    <asp:ValidationSummary ID="ValidationSummary1" runat="server" EnableClientScript="true"
        HeaderText="List of validation errors" />
    <asp:DynamicValidator runat="server" ID="DetailsViewValidator" ControlToValidate="DetailsView1" Display="None" />

    <asp:DetailsView ID="DetailsView1" runat="server" DataSourceID="DetailsDataSource" DefaultMode="Insert"
        AutoGenerateInsertButton="True" OnItemCommand="DetailsView1_ItemCommand" OnItemInserted="DetailsView1_ItemInserted"
        CssClass="detailstable" FieldHeaderStyle-CssClass="bold"

    <asp:LinqDataSource ID="DetailsDataSource" runat="server" EnableInsert="true">

적용 대상