Databases Reference
In-Depth Information
LISTING 12.2 Continued
public int DataItemIndex { get; internal set; }
public int DisplayIndex { get; internal set; }
}
}
Code-behind of the Parent field template is shown in Listing 12.3. Notice the public
DisplayField property, which is set as a custom attribute in page markup to specify the
name of the property of the parent entity the template needs to display.
LISTING 12.3 Parent Field Template (Code-Behind)
using System;
using System.Web.UI;
using System.Web.DynamicData;
namespace WebApplication.DynamicData.FieldTemplates
{
public partial class ParentFieldTemplate : UnleashedFieldTemplate
{
public override Control DataControl
{
get { return this.control.FieldTemplate.DataControl; }
}
public string DisplayField { get; set; }
protected void Control_Init(object sender, EventArgs args)
{
this.container.SetMetaTable(this.ForeignKeyColumn.ParentTable);
this.control.DataField = this.DisplayField;
}
protected override void OnDataBinding(EventArgs e)
{
this.container.DataItem = this.FieldValue;
base.OnDataBinding(e);
}
}
}
The Control_Init method uses the DisplayField property to initialize the DataField
property of the nested UnleashedControl ; however, that is only half the information
it needs to locate the MetaColumn describing the parent entity property. The
Search WWH ::




Custom Search