共用方式為


Fields 屬性

傳回 ObjectListFieldCollection 類別中明確定義的欄位集合。

public System.Web.UI.MobileControls.ObjectListFieldCollection Fields {
   get
}

備註

若要加入或移除集合欄位,請使用 ObjectListFieldCollection 類別的 AddAddAtRemoveRemoveAt 方法。

範例

下列範例示範如何使用 Fields 屬性將 ObjectListField 項目加入至ObjectListFieldCollection

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
   
   If Not IsPostBack Then
      
      ObjectList1.AutoGenerateFields = False
      ' Add the ObjectListFields item to the ObjectListFieldCollection
      ' of ObjectList1.
      Dim ListField1 As New ObjectListField()
      ListField1.DataField = "BookName"
      ListField1.Title = "BookName"
      ObjectList1.Fields.Add(ListField1)
   
   End If

End Sub

[C#]
public void Page_Load(Object sender, EventArgs e)
{
   if(!IsPostBack)
   {
      ObjectList1.AutoGenerateFields = false ;

      // Add the ObjectListFields item to the ObjectListFieldCollection
      // of ObjectList1.
      ObjectListField ListField1 = new ObjectListField();
      ListField1.DataField = "BookName";
      ListField1.Title = "BookName";
      ObjectList1.Fields.Add(ListField1);
   }
}

請參閱

套用至:ObjectList 類別