1

我正在使用Repeater控件来显示数据,数据源包含在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>
4

2 回答 2

2

正如你所说,它只是第一次工作,所以替换你的这条线

if (e.Item.ItemType == ListItemType.Item)

和....

 if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType==ListItemType.AlternatingItem)
于 2013-04-10T05:59:55.650 回答
0
  1. 给出[xp:repeat] 一个 ID 值,例如idvaluestring
  2. 在 SSJS 中使用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() 
于 2018-11-02T19:15:07.670 回答