我使用Repeater控件来显示数据,数据源包含多个记录 在转发器中显示的,我需要的是获取两个列表项的差异并将其分配给另一个列表项,我使用下面提到的代码适用于第一个记录,但不显示所有记录
aspx.cs代码
DataSet dsJobCardHistory =new DataSet();
double dcPriceIncl;
double dcPriceExcl;
double dcTax;
protected void Job_History()
{
dsJobCardHistory = objReportManager.Get_JobCard_History(strCustNo, strTranId);
dcPriceIncl = Convert.ToDouble(dsJobCardHistory.Tables[0].Rows[0][6].ToString());
dcTax = dcPriceIncl * 0.14;
dcPriceExcl = dcPriceIncl - dcTax;
}
protected void repJobCard_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item)
{
((Label)e.Item.FindControl("lblRepPrice")).Text =
Convert.ToString(dcPriceExcl);
((Label)e.Item.FindControl("lblRepTax")).Text =
Convert.ToString(dcTax);
((Label)e.Item.FindControl("lblRepTotal")).Text=
Convert.ToString(dcPriceIncl);
}
}
}
aspx代码
<font style="font-size:14px"><strong><asp:Label ID="lblRepPrice" runat="server"
Text=""></asp:Label></strong></font>
</td>
<td align="center" width="15%">
<font style="font-size:14px"><strong><asp:Label ID="lblRepTax" runat="server"
Text=""></asp:Label></strong></font>
</td>
<td align="center" width="15%">
<font style="font-size:14px"><strong><asp:Label ID="lblRepTotal" runat="server"
Text=""></asp:Label></strong></font>
</td>
答案 0 :(得分:2)
正如你所说,它只是第一次工作所以替换你的这条线
if (e.Item.ItemType == ListItemType.Item)
...与
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType==ListItemType.AlternatingItem)
答案 1 :(得分:0)
[xp:repeat]
一个ID值,例如idvaluestring
getComponent("idvalueString").getRowCount()
RepeatControl的类为:
com.ibm.xsp.component.xp.XspDataIterator
<xp:repeat var="voyageChoicesCollection"
indexVar="voyageChoicesCollectionIndex"
value="#{ProfileListRepeat}"
id="voyageChoicesCollectionID">
var vccID:com.ibm.xsp.component.xp.XspDataIterator = getComponent("voyageChoicesCollectionID");
vccID.getRowCount()