共用方式為


MetaModel.VisibleTables 屬性

定義

取得資料模型中可見資料表的集合。

public:
 property System::Collections::Generic::List<System::Web::DynamicData::MetaTable ^> ^ VisibleTables { System::Collections::Generic::List<System::Web::DynamicData::MetaTable ^> ^ get(); };
public System.Collections.Generic.List<System.Web.DynamicData.MetaTable> VisibleTables { get; }
member this.VisibleTables : System.Collections.Generic.List<System.Web.DynamicData.MetaTable>
Public ReadOnly Property VisibleTables As List(Of MetaTable)

屬性值

List<MetaTable>

可見資料表意指已啟用 Scaffolding 的資料表, 也就是 List.aspx 頁面所存在的資料表。

範例

下列範例示範如何使用 VisibleTables 屬性來取得資料模型中可見資料表的集合。 如需完整範例,請參閱 MetaModel 類別概觀。

// Gets only the visible tables in the data model.
protected void GetVisibleTables()
{
     System.Collections.IList visibleTables =
         MetaModel.Default.VisibleTables;
     if (visibleTables.Count == 0)
     {
         throw new InvalidOperationException(
             "There are no accessible tables. Make sure that at least one data model is registered in Global.asax and scaffolding is enabled or implement custom pages.");
     }
     Menu1.DataSource = visibleTables;
     Menu1.DataBind();
}
' Gets only the visible tables in the data model.
Protected Sub GetVisibleTables()
    Dim visibleTables As System.Collections.IList = MetaModel.[Default].VisibleTables
    If visibleTables.Count = 0 Then
        Throw New InvalidOperationException("There are no accessible tables. Make sure that at least one data model is registered in Global.asax and scaffolding is enabled or implement custom pages.")
    End If
    Menu1.DataSource = visibleTables
    Menu1.DataBind()
End Sub

適用於