using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.DynamicData; using System.Web.Security; using Aspnet.Samples.DynamicData; namespace TicketCenter_DynamicData { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { 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(); } // It obtains the action path for a custom or standard view. // Note the following: // a) You must define the related custom view (template) in the DynamicData/PageTemplates folder. // b) You must also define the route in the Global.asax file. // c) You must apply the SecurityAttribute to the tables you want to display. // Inline syntax: // NavigateUrl='<%# ((MetaTable)Page.GetDataItem()).GetActionPath // "AnonymousList") %>'> protected string GetActionPath(string view) { string actionPath = String.Empty; // Instantiate the SecurityInformation // utility object. DynamicDataSecurity secInfo = new DynamicDataSecurity(); if (secInfo.IsUserInAdmimistrativeRole() || secInfo.IsUserInAuthenticatedRole()) actionPath = ((MetaTable)Page.GetDataItem()).GetActionPath(PageAction.List); else // For non authenticated users allow limited // functionality as defined in Global.asax. actionPath = ((MetaTable)Page.GetDataItem()).GetActionPath(view); return actionPath; } } }