DynamicDataManager.RegisterControl 方法

定義

註冊 DynamicDataManager 控制項。

多載

RegisterControl(Control)

DynamicDataManager 控制項註冊控制項。

RegisterControl(Control, Boolean)

DynamicDataManager 控制項註冊控制項。

RegisterControl(Control)

DynamicDataManager 控制項註冊控制項。

public:
 void RegisterControl(System::Web::UI::Control ^ control);
public void RegisterControl (System.Web.UI.Control control);
member this.RegisterControl : System.Web.UI.Control -> unit
Public Sub RegisterControl (control As Control)

參數

control
Control

要註冊的資料控制項。

範例

下列範例示範如何在 ASP.NET 網頁的 方法中 Page_Init 註冊 System.Web.UI.WebControls.GridView 控制項。

<%@ Page Language="C#" MasterPageFile="~/Site.master" %>

<script runat="server">

    protected void Page_Init(object sender, EventArgs e) {
        DynamicDataManager1.RegisterControl(GridView1);
    }

</script>



<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">

    <h1> DynamicDataManager VB Sample</h1>
    
    <asp:DynamicDataManager ID="DynamicDataManager1" runat="server" 
        AutoLoadForeignKeys="true" />
    
    <asp:GridView ID="GridView1" runat="server" DataSourceID="GridDataSource" AllowPaging="True"
        AllowSorting="True" CssClass="gridview">
    </asp:GridView>
    
    <asp:LinqDataSource ID="GridDataSource" runat="server" EnableDelete="true">
       
    </asp:LinqDataSource>
    
</asp:Content>
<%@ Page Language="VB" MasterPageFile="~/Site.master" %>

<script runat="server">

    Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)
        DynamicDataManager1.RegisterControl(GridView1)
    End Sub

</script>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
        
<h1> DynamicDataManager CS Sample</h1>

    <asp:DynamicDataManager ID="DynamicDataManager1" runat="server"
         AutoLoadForeignKeys="true" />

    <asp:GridView ID="GridView1" runat="server" DataSourceID="GridDataSource"
        AllowPaging="True" AllowSorting="True" CssClass="gridview">
    </asp:GridView>

    <asp:LinqDataSource ID="GridDataSource" runat="server" EnableDelete="true">
    </asp:LinqDataSource>
    
</asp:Content>

備註

若要在控制項中啟用動態行為,您必須註冊它。

適用於

RegisterControl(Control, Boolean)

DynamicDataManager 控制項註冊控制項。

public:
 void RegisterControl(System::Web::UI::Control ^ control, bool setSelectionFromUrl);
public void RegisterControl (System.Web.UI.Control control, bool setSelectionFromUrl);
member this.RegisterControl : System.Web.UI.Control * bool -> unit
Public Sub RegisterControl (control As Control, setSelectionFromUrl As Boolean)

參數

control
Control

要註冊的資料控制項。

setSelectionFromUrl
Boolean

true 表示使用主索引鍵設定所選項目,否則未設定所選項目。

備註

註冊控制項會啟用其動態行為。 setSelectionFromUrl如果 參數是 true ,而且在路由值中找到主鍵值,則會使用主鍵來設定選取的專案。 主要索引鍵值通常會使用要求 URL 中的查詢字串,在路由中傳遞。

適用於