|
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DaveControls.HierarchicalControls.Data;
namespace Samples
{
public partial class SimpleStaticHierarchicalRepeater : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
SimpleHierarchicalRepeater.DataSource = TestDataSource;
SimpleHierarchicalRepeater.DataBind();
}
}
/// <summary>
/// This is the data source the HierarchicalRepeater control will be data bound to.
/// The HierarchicalRepeater control requires its datasource object to inherit HierarchyDataItemBase
/// </summary>
private SimpleTestData _testDataSource;
private SimpleTestData TestDataSource
{
get
{
if (_testDataSource == null)
{
SimpleTestData testDataSource = new SimpleTestData("rootItem");
testDataSource.Add(new SimpleTestData("Pie"));
testDataSource.Add(new SimpleTestData("Cake"));
SimpleTestData item3 = new SimpleTestData("Fruit");
SimpleTestData item3a = new SimpleTestData("Apples");
SimpleTestData item3b = new SimpleTestData("Pears");
SimpleTestData item3c = new SimpleTestData("Oranges");
item3.Add(item3a);
item3.Add(item3b);
item3.Add(item3c);
SimpleTestData item3a1 = new SimpleTestData("Granny Smith");
SimpleTestData item3a2 = new SimpleTestData("Goldern Delicious");
item3a.Add(item3a1);
item3a.Add(item3a2);
testDataSource.Add(item3);
testDataSource.Add(new SimpleTestData("Crisps"));
_testDataSource = testDataSource;
}
return _testDataSource;
}
}
/// <summary>
/// This class represents the datasource and dataitems the HierarchicalRepeater control will bind to.
/// It inherits HierarchyDataItemBase as required, and the additional properties are specific to this
/// sample and can be data bound to in the ItemTemplate, ChildrenHeaderTemplate and FooterHeaderTemplate
/// of the control.
/// </summary>
private class SimpleTestData : HierarchyDataItemBase
{
private string _text;
public string Text
{
get { return _text; }
set { _text = value; }
}
public SimpleTestData(string text)
{
_text = text;
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.