This is my C# Backend:
protected void Page_Load(object sender, EventArgs args)
{
CaseEnt MyCase = McHenryLib.ICISAdapters.CaseAdapter.GetCaseRecordForCaseNumber(Globals.CaseNum);
List<Charge> charges = McHenryLib.ICISAdapters.ChargeAdapter.GetByCaseNumber(Globals.CaseNum);
rptChg.DataSource = charges;
rptChg.DataBind();
}
protected void rptChg_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
CaseEnt MyCase = McHenryLib.ICISAdapters.CaseAdapter.GetCaseRecordForCaseNumber(Globals.CaseNum);
List<Charge> charges = McHenryLib.ICISAdapters.ChargeAdapter.GetByCaseNumber(Globals.CaseNum);
if (charges != null && charges.Count > 0)
{
List<Sentence> sentences = new List<Sentence>();
foreach (Charge chg in charges)
{
Repeater rptSen = (Repeater)(e.Item.FindControl("rptSen"));
sentences.AddRange(McHenryLib.ICISAdapters.SentenceAdapter.GetByChargeObjectID(chg.ChargeObjectID));
if (sentences != null && sentences.Count > 0)
{
List<SentenceDisposition> disps = new List<SentenceDisposition>();
foreach (Sentence sen in sentences)
{
Repeater rptDisp = (Repeater)(e.Item.FindControl("rptDisp"));
disps.AddRange(McHenryLib.ICISAdapters.SentenceDispositionAdapter.GetDispositionsBySentenceOID(sen.SentenceID));
rptDisp.DataSource = disps;
rptDisp.DataBind();
}
}
rptSen.DataSource = sentences;
rptSen.DataBind();
}
}
}
This is my ASP.NET frontend:
<asp:Repeater ID="rptChg" runat="server" OnItemDataBound="rptChg_ItemDataBound">
<ItemTemplate>
<br />
<table class="chg">
<tr>
<th>Count <%#Eval("Counts") %></th>
</tr>
</table>
<!--Builds the Charges Table-->
<table class="chg">
<tr>
<th>Charge Date</th>
<th>Statute</th>
<th>Description</th>
<th>Disposition/Manner</th>
</tr>
<tr>
<td><%#Eval("ChargeDate")%></td>
<td><%#Eval("Statute")%></td>
<td><%#Eval("StatuteDesc")%></td>
<td><%#ChgCode(Eval("Disposition"))%></td>
</tr>
</table>
<!--Builds the Sentences Table-->
<table class="sen">
<asp:Repeater ID="rptSen" runat="server">
<HeaderTemplate>
<th colspan="3">Sentences</th>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><%#Eval("SentenceDate")%></td>
<td><%#Eval("TypeDesc")%></td>
<td><%#ZeroToNull(Eval("UnitTerm"))%> <%#ZeroToNullMoney(Eval("Amount"))%> <%#Eval("UnitTypeDesc")%></td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
I'm trying to get the Sentences table to repopulate for every new instance of the Charge table, with nested repeaters. However, I've tried a couple different solutions but every time the Sentences table just spits out the same data from the first charge onto all of them.
I've stepped through the code a few times, and I noticed that when it goes to DataBind the second Sentences table, the repeater's ClientID doesn't change, which makes me think that it's not rolling over a new instance of the repeater every time, and is instead just repeating the same data every time.
My question is: is there a way to have it manually roll a new sequential ClientID, so that it binds to the correct repeater each time? Or am I going about this completely the wrong way entirely?