Avatar of EricFleet
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);
                    
                }
...

Open in new window

ASP.NETC#

Avatar of undefined
Last Comment
EricFleet

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
EricFleet

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes