public partial class ForRepeater : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
BindData();
}
}
private void BindData()
{
Repeater1.DataSource = GetDataTable1();
Repeater1.DataBind();
}
private DataTable GetDataTable1()
{
DataTable table1 = (DataTable)Cache["TooltipDataSource1"];
if (table1 == null)
{
table1 = new DataTable();
table1.Columns.Add("MyId", typeof(int));
table1.Columns.Add("Image", typeof(String));
table1.Columns.Add("Thumbnail", typeof(String));
XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath("~/Tooltip/RepeaterData.xml"));
XmlNodeList nodes = doc.DocumentElement.ChildNodes;
for (int i = 0; i < nodes.Count; i++ )
{
table1.Rows.Add(new object[] { i,
nodes[i].Attributes["src"].Value, nodes[i].Attributes["thumbnailsrc"].Value });
}
Cache.Insert("TooltipDataSource1", table1, null,
System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(10));
}
return table1;
}
}