Databases Reference
In-Depth Information
LISTING 6.6 List Page Template (Code-Behind)
using System;
using System.Collections.Generic;
using System.Web.DynamicData;
using System.Web.Routing;
using System.Web.UI.WebControls;
namespace WebApplication.DynamicData.PageTemplates
{
public partial class List : System.Web.UI.Page
{
protected MetaTable table;
protected void Page_Init(object sender, EventArgs e)
{
this.table = DynamicDataRouteHandler.GetRequestMetaTable(this.Context);
this.Title = this.table.DisplayName;
this.dataSource.EntityTypeFilter = this.table.EntityType.Name;
this.dataSource.Include = table.ForeignKeyColumnsNames;
IDictionary<string, object> columnValues =
this.table.GetColumnValuesFromRoute(this.Context);
this.gridView.SetMetaTable(this.table, columnValues);
this.insertLink.NavigateUrl = this.table.GetActionPath(
PageAction.Insert, new RouteValueDictionary(columnValues));
}
protected void Label_PreRender(object sender, EventArgs e)
{
var label = (Label)sender;
var dynamicFilter = (DynamicFilter)label.FindControl(“DynamicFilter”);
var template = dynamicFilter.FilterTemplate as QueryableFilterUserControl;
if (template != null && template.FilterControl != null)
{
label.AssociatedControlID =
template.FilterControl.GetUniqueIDRelativeTo(label);
}
}
protected void DynamicFilter_FilterChanged(object sender, EventArgs e)
{
this.gridView.PageIndex = 0;
}
}
}
Search WWH ::




Custom Search