如何从中继器控件中获取最后的记录值?

发布于 2024-12-04 02:05:34 字数 95 浏览 4 评论 0原文

我想从中继器控件中获取最后一条记录的详细信息。有人可以帮忙吗?

更详细: 在我的数据库中插入了天数。最后记录显示旅行的总天数。所以我想要来自重复的最后一个记录值

I want to get the last record detail from repeater control. can someone help?

more detail :
in my database there is number of days inserted. the last record shows the total days of tours. so i want that last record value from repea

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小红帽 2024-12-11 02:05:34

在后面的代码中,您可以使用 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
        }            
    }
}

In code behind you can use the ItemDataBound event to get the details of the last item:

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
        }            
    }
}
茶花眉 2024-12-11 02:05:34
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");
            }
        }
    }
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");
            }
        }
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文