我想从中继器控制中心得到最新的记录细节。有人能帮帮忙吗?
更多细节:在我的数据库中有插入的天数。最后一个记录显示了旅游的总天数。所以我想要来自repea最后一个记录值
发布于 2011-09-10 20:41:51
在后台代码中,您可以使用ItemDataBound事件来获取最后一项的详细信息:
protected void rpt_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item ||
e.Item.ItemType == ListItemType.AlternatingItem)
{
if (e.Item.ItemIndex == rpt.Items.Count - 1)
{
// this repeater item refers to the last record
}
}
}发布于 2019-10-29 12:58:25
protected void rptUserStat_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
//reference the repeater item.
RepeaterItem item = e.Item;
//reference the controls.
Label lbltotal = (item.FindControl("lblgoldname") as Label);
Label lblamount = (item.FindControl("lblgoldDonationAmount") as Label);
if (lbltotal.Text.ToUpper() == "TOTAL")
{
int footerindex = e.Item.ItemIndex;
HtmlTableRow htmlrow = (HtmlTableRow)e.Item.FindControl("trgold");
htmlrow.BgColor = "#DDCECB";
lbltotal.Style.Add("Font-Weight", "bold");
lbltotal.Style.Add("color", "cadetblue");
lblamount.Style.Add("Font-Weight", "bold");
lblamount.Style.Add("color", "cadetblue");
}
}
}https://stackoverflow.com/questions/7371680
复制相似问题