我使用转发器控件来显示在 ItemDataBound 事件期间绑定了三个项目的数据,代码的问题是最后一条记录显示在转发器的所有行中,覆盖了已经存在的值,我该如何停止呢?我使用这样的代码
.aspx.cs 代码
DataSet dsJobCardHistory =new DataSet();
double dcPriceIncl;
double dcPriceExcl;
double dcTax;
protected void Job_History()
{
dsJobCardHistory = objReportManager.Get_JobCard_History(strCustNo, strTranId);
}
protected void repJobCard_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
for (int i = 0; i < dsJobCardHistory.Tables[0].Rows.Count;i++)
{
dcPriceIncl = Convert.ToDouble(dsJobCardHistory.Tables[0].Rows[i][6].ToString());
dcTax = dcPriceIncl * 0.14;
dcPriceExcl = dcPriceIncl - dcTax;
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType==
ListItemType.AlternatingItem)
{
((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 代码
<asp:Repeater ID="repJobCard" runat="server" onitemdatabound="repJobCard_ItemDataBound">
<td align="center" width="15%">
<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>