Search code examples
c#asp.netrepeater

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


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


Solution

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