Databases Reference
In-Depth Information
NOTE
Although the name DynamicLabel would be more appropriate for this particular control,
it is called UnleashedLabel . To avoid confusion and clearly distinguish them from the
built-in controls provided by Dynamic Data, you will see the Unleashed prefix used for
all new and extended controls created in this topic.
Listing 10.8 shows the source code of this control with some of the error-handling logic
removed to make it easier to read. You can find the complete source code of this control
in the Unleashed.DynamicData project of the solution accompanying this topic.
LISTING 10.8 UnleashedLabel Implementation
using System;
using System.ComponentModel;
using System.Web.DynamicData;
using System.Web.UI.WebControls;
namespace Unleashed.DynamicData
{
public class UnleashedLabel : Label
{
[DefaultValue(“”)]
public string DataField
{
get
{
object obj = this.ViewState[“DataField”];
return obj != null ? (string)obj : string.Empty;
}
set
{
this.ViewState[“DataField”] = value;
}
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
MetaTable table = this. FindMetaTable ();
MetaColumn column = table.GetColumn(this.DataField);
this.Text = column.DisplayName;
}
protected override void OnPreRender(EventArgs e)
{
Search WWH ::




Custom Search