RadListview Groups total

2 posts, 0 answers
  1. Bassem
    Bassem avatar
    14 posts
    Member since:
    Jul 2012

    Posted 11 Mar 2014 Link to this post

    My question is very simple i have a listview with multiple group in it ,what is the best way to display the to total of all the groups at once .the functionality of the radlistview is set to display the total of each group individually but i need to set the total of total in other words the somme of all the groups total .is that possible(is there any parameter inside the radlistview to set ) ? or should i do it from code 
  2. Konstantin Dikov
    Konstantin Dikov avatar
    2406 posts

    Posted 14 Mar 2014 Link to this post

    Hello Bassem,

    Such functionality is not available out of the box, but it is possible to accomplish it in the code-behind, by handling the server-side ItemDataBound event of the grid (for retrieving the DataGroupItems aggregates) and the server-side PreRender event for setting the value.

    If we use the ListView - DataGrouping online demo as a reference, we could add a Label control in the LayoutTemplate that will hold the sum of all groups aggregates:
        <div class="listLayout">
            <asp:Label ID="AllGroupsSum" runat="server"></asp:Label>

    And the code-behind for the ItemDataBound and PreRender events:
    private double priceSum = 0;
    protected void RadListView1_ItemDataBound(object sender, RadListViewItemEventArgs e)
        if (e.Item is RadListViewDataGroupItem)
            RadListViewDataGroupItem item = e.Item as RadListViewDataGroupItem;
            priceSum += double.Parse(item.AggregatesValues["Price"].ToString());
    protected void RadListView1_PreRender(object sender, EventArgs e)
        RadListView listView = sender as RadListView;
        Label allGroupsSumLabel = listView.FindControl("AllGroupsSum") as Label;
        if (allGroupsSumLabel != null)
            allGroupsSumLabel.Text = priceSum.ToString();  

    Please let me know if that helps with your requirement.

    Konstantin Dikov

    DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

Back to Top