开发者

How can i get last record value from repeater control.?

开发者 https://www.devze.com 2023-04-04 03:27 出处:网络
I want to get the last record detail from repeater control. can开发者_高级运维 someone help? more detail :

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


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
        }            
    }
}


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");
            }
        }
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消