HI Lan Huang
Yes, I am proceeding with a repeater control, the repeater control is created at the code behind, say if I have a collection of lists, for every list a method is run which creates the control and subsequently displays the data.
Here is the code : -
List<List<Bottleneckv11.SelectAllPU_Result>> groupedList = pulist.ToList()
.GroupBy(u => u.ProcessTypeName)
.Select(grp => grp.ToList())
.ToList();
for(int i = 0; i < groupedList.Count; i++)
{
CreateDynamicRepeater(groupedList[i]);
}
internal void CreateDynamicRepeater(List<Bottleneckv11.SelectAllPU_Result> sublist)
{
Repeater rpt = new Repeater();
ITemplate header = LoadTemplate("rpthdr.ascx");
rpt.HeaderTemplate = header;
//rpt.HeaderTemplate = header;
TemplateBuilder itemTemplate = new TemplateBuilder();
for (int i = 0; i< sublist.Count; i++)
{
itemTemplate.AppendLiteralString("<tr>");
itemTemplate.AppendLiteralString("<td>" + sublist[i].ProcessUnitID + "</td>");
itemTemplate.AppendLiteralString("<td>" + sublist[i].ProcessUnitName + "</td>");
itemTemplate.AppendLiteralString("<td>" + sublist[i].JobOrderName + "</td>");
itemTemplate.AppendLiteralString("<td>" + i + "</td>");
itemTemplate.AppendLiteralString("<td>" + sublist[i].Result + "</td>");
itemTemplate.AppendLiteralString("<td>" + sublist[i].TotalAvailable + "</td>");
itemTemplate.AppendLiteralString("</tr>");
}
rpt.ItemTemplate = itemTemplate;
TemplateBuilder footer = new TemplateBuilder();
footer.AppendLiteralString("<tr><td>End of Table</td></tr></table>");
rpt.FooterTemplate = footer;
rpt.DataSource = sublist;
rpt.DataBind();
this.Controls.Add(rpt);
}
Right now, the data is displayed but it is repeated and this is how it looks now. I do not want the data to be repeated. It gets repeated based on the count of list. I think I am doing something wrong with the template builder. Please see if you could help.