Databases Reference
In-Depth Information
from the CustomPropertyAttribute if it is available. Listing 13.11 shows the updated
source code of the class.
LISTING 13.11 UnleashedField Implementation with SortExpression Property
using System.Linq;
using System.Web.DynamicData;
using Unleashed.DataAnnotations;
namespace Unleashed.DynamicData
{
public class UnleashedField : DynamicField
{
public override string SortExpression
{
get
{
object obj = this.ViewState[“SortExpression”];
if (obj != null) return (string)obj;
if (this.Column != null)
{
CustomPropertyAttribute property = this.Column.Attributes
.OfType<CustomPropertyAttribute>().FirstOrDefault();
if (property != null && !string.IsNullOrEmpty(property.Expression))
return property.Expression;
return this.Column.SortExpression;
}
return string.Empty;
}
set { base.SortExpression = value; }
}
protected override DynamicControl CreateDynamicControl()
{
return new UnleashedControl();
}
}
}
Search WWH ::




Custom Search