我正在尝试在转发器的项目数据绑定内循环一个字段但是在第一个真值后它失败并且站点停止绑定控件的其余部分
protected void rptPayments_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
DataRowView drv = e.Item.DataItem as DataRowView;
bool isInArrears = (bool) drv.Row["isinArrears"];
}
}
影响是它只打印它在db中找到的第一个项,其值为true,但我的转发器源查找所有值,无论它们是真还是假。
isinArrears
是数据库中的布尔字段,有人可以帮我解决。我还需要更改<div class="panel panel-default">
div以表示成功或失败。
<div class="panel-group" id="accordion">
<asp:Repeater ID="rptPayments" runat="server" OnItemDataBound="rptPayments_ItemDataBound">
<ItemTemplate>
<div class="panel panel-default">
<div class="panel-heading pointer" data-toggle="collapse" data-parent="#accordion" href="#collapse<%#Container.ItemIndex %>">
<div class="alert-box notice">
<h4 class="panel-title">
<asp:HiddenField ID="isinArrears" runat="server" Value='<%#Eval("isinArrears") %>' />
<a><%# Convert.ToDateTime(Eval("paymentDate")).ToString("MMMM d yyyy") %> </a><i class="fa fa-info-circle" aria-hidden="true"></i>
</h4>
</div>
</div>
<div id="collapse<%#Container.ItemIndex %>" class="<%# GetItemClass(Container.ItemIndex) %>" style="height: auto;">
<div class="panel-body">
<!-- <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.Lorem ipsum dolor sit amet, consectetur adipiscing elit.Lorem ipsum dolor sit amet, consectetur adipiscing elit.Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>-->
<div class="col-md-4">
<p>
Payment Agreed:
<dx:ASPxLabel ID="lblPaymentsPerMonth" runat="server" Text='<%# Eval("agreedPaymentsPerMonth") %>'></dx:ASPxLabel>
</p>
</div>
<div class="col-md-4">
<p>
Payment Date:
<dx:ASPxLabel ID="lblPayemntDate" runat="server" Text='<%# Convert.ToDateTime(Eval("paymentDate")).ToString("dd/MM/yyyy") %>'></dx:ASPxLabel>
</p>
</div>
<div class="col-md-4">
<p>
Payment Due:
<dx:ASPxLabel ID="lblPaymentDUE" runat="server" Text='<%# Eval("paymentDue") %>'></dx:ASPxLabel>
<br />
<br />
</p>
<i class="fa fa-fw" aria-hidden="true" title="Copy to use check-circle-o"></i>
</div>
<div class="col-md-4">
<p>
Arreas:
<dx:ASPxLabel ID="ASPxLabel1" runat="server" Text='<%# Eval("isinArrears") %>'></dx:ASPxLabel>
</p>
</div>
</div>
</div>
</div>
</ItemTemplate>
</asp:Repeater>
这就是我使用linq填充我的asp转发器的方法。
public List<tblPortalPayment> getUserPayments(Guid recordId)
{
List <tblPortalPayment> _payments= portalEntities.tblPortalPayments.Where(a=>a.CustomerId== recordId && a.isDeleted==false).ToList();
return _payments;
}