我正在使用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>