共用方式為


EnsureTemplatedUI 方法 (通用)

使用此方法,確定樣板已具現化,並可用程式設計的方式存取具現化的樣板內容。

public virtual void EnsureTemplatedUI()

備註

ListObjectList 類別覆寫此方法。

public override void EnsureTemplatedUI()

範例

下列範例示範如何使用 EnsureTemplatedUI 方法存取 ObjectList 詳細資料檢視內 Label1 控制項的內容。

Sub OnCmdClick(sender As Object, e As EventArgs)

   ObjectList1.EnsureTemplatedUI()
   ObjectList1.ViewMode = ObjectListViewMode.Details
   CType(ObjectList1.Details.FindControl("Label1"), System.Web.UI.MobileControls.Label).Text = "New Tasks"
   
End Sub

<Mobile:Form id="WelcomeForm" runat="server">
   <mobile:objectList id="ObjectList1" runat="server" CommandStyle- 
   StyleReference="subcommand" LabelStyle-StyleReference="title">
       <DeviceSpecific>
          <Choice>
             <ItemDetailsTemplate>
                <mobile:label id="Label1" runat="server" Text="Task List"  
                 Font-Bold="true"></mobile:label>
                 <mobile:Command id="Command1" runat="server"  
                  OnClick="OnCmdClick">Command</mobile:Command>
             </ItemDetailsTemplate>
          </Choice>
        </DeviceSpecific>
    </mobile:objectList>
</Mobile:Form>

[C#]

void OnCmdClick(object sender, EventArgs e)
{
  ObjectList1.EnsureTemplatedUI();
  ObjectList1.ViewMode = ObjectListViewMode.Details;
  ((Label)ObjectList1.Details.FindControl("Label1")).Text = "New Tasks";
}

<Mobile:Form id="WelcomeForm" runat="server">
   <mobile:objectList id="ObjectList1" runat="server" CommandStyle- 
   StyleReference="subcommand" LabelStyle-StyleReference="title">
       <DeviceSpecific>
          <Choice>
             <ItemDetailsTemplate>
                <mobile:label id="Label1" runat="server" Text="Task List"  
                 Font-Bold="true"></mobile:label>
                 <mobile:Command id="Command1" runat="server"  
                  OnClick="OnCmdClick">Command</mobile:Command>
             </ItemDetailsTemplate>
          </Choice>
        </DeviceSpecific>
    </mobile:objectList>
</Mobile:Form>

請參閱

套用至:List 類別 | MobileControl 類別 | ObjectList 類別