private void SetTemplates()
{
foreach (DataControlField c in this.Columns)
{
if (c is CarrotHeaderSortTemplateField)
{
CarrotHeaderSortTemplateField ctf = (CarrotHeaderSortTemplateField)c;
ctf.HeaderTemplate = new CarrotSortButtonHeaderTemplate(ctf.HeaderText, ctf.SortExpression);
if (string.IsNullOrEmpty(ctf.DataField) && !string.IsNullOrEmpty(ctf.SortExpression))
{
ctf.DataField = ctf.SortExpression;
}
if (ctf.ItemTemplate == null)
{
if (!string.IsNullOrEmpty(ctf.DataField) && !ctf.ShowBooleanImage && !ctf.ShowEnumImage)
{
ctf.ItemTemplate = new CarrotAutoItemTemplate(ctf.DataField, ctf.DataFieldFormat);
}
if (ctf.ShowBooleanImage && !ctf.ShowEnumImage)
{
CarrotBooleanImageItemTemplate iImageItemTemplate = new CarrotBooleanImageItemTemplate(ctf.DataField, ctf.BooleanImageCssClass);
if (!string.IsNullOrEmpty(ctf.AlternateTextTrue) || !string.IsNullOrEmpty(ctf.AlternateTextFalse))
{
iImageItemTemplate.SetVerbiage(ctf.AlternateTextTrue, ctf.AlternateTextFalse);
}
if (!string.IsNullOrEmpty(ctf.ImagePathTrue) || !string.IsNullOrEmpty(ctf.ImagePathFalse))
{
iImageItemTemplate.SetImage(ctf.ImagePathTrue, ctf.ImagePathFalse);
}
ctf.ItemTemplate = iImageItemTemplate;
}
if (ctf.ShowEnumImage)
{
ctf.ItemTemplate = new CarrotImageItemTemplate(ctf.DataField, ctf.BooleanImageCssClass, ctf.ImageSelectors);
}
}
}
}
}