EricFleet
asked on
Repeater Control -- Adding another table row
I am trying to add some subtotals to a repeater control. Basically, repeater is bound to a dataset. Each record of the dataset creates a new table row. The subtotaler should detect when the date has changed in the data and insert a row. I am able to do this, but unfortunately it occurs AFTER the change, so the subtotal appears the row after the date has changed. I need it to occur before. I am using e.Item.Controls.Add to create this row dynamically in code. I have tried AddAt() with no success.
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
// Customize each item based on data.
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
DataRowView row = e.Item.DataItem as DataRowView;
if (DateTime.Parse(row["RecordDate"].ToString()) != lastdate)
{
lastdate = DateTime.Parse(row["RecordDate"].ToString());
HtmlTableRow tr = new HtmlTableRow();
tr.BgColor = "FFFFD0";
HtmlTableCell tc = new HtmlTableCell();
tc.InnerText = "testing...";
HtmlTableCell tc2 = new HtmlTableCell();
tc2.InnerText = "more testing...";
tr.Cells.Add(tc);
tr.Cells.Add(tc2);
e.Item.Controls.Add(tr);
}
...
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.