Posts

Showing posts from 2010

ListView Alternating Group Template

The ListView have no such thing as alternating the group templates and still is so much needed.


public class aiListView : ListView
{
int groupDisplayIndex = 1; /*update on June 16, 2010*/
private ITemplate _alternatingGroupTemplate;
public virtual ITemplate AlternatingGroupTemplate
{
get { return _alternatingGroupTemplate; }
set { _alternatingGroupTemplate = value; }
}

protected override void InstantiateGroupTemplate(System.Web.UI.Control container)
{

ITemplate template = this._alternatingGroupTemplate;
if (_alternatingGroupTemplate != null && GroupItemCount > 0 && groupDisplayIndex % 2 == 0 /*update on June 16, 2010*/)
{
template = this._alternatingGroupTemplate;
}
else
{
template = this.GroupTemplate;
}

template.InstantiateIn(container);
grou…