This is a migrated thread and some comments may be shown as answers.

Show Column avg/sum inside the pager template

2 Answers 65 Views
Grid
This is a migrated thread and some comments may be shown as answers.
naimish
Top achievements
Rank 1
naimish asked on 28 Sep 2010, 05:18 PM
Hi,

I am using radgrid for showing database data, and in footer section, i am showing average of  one column data.
Now beside that i need to show that average to the some where inside pager template region.

But i dont know how can i show that thing inside pager region.

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 29 Sep 2010, 06:49 AM
Hello Naimish,


The following code will help you in this.

Code:
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
    GridFooterItem footerItem = (GridFooterItem)RadGrid1.MasterTableView.GetItems(GridItemType.Footer)[0];
    string value = footerItem["Number"].Text; // get the value usingColumnUniqueName
    foreach (GridPagerItem pagerItem in RadGrid1.MasterTableView.GetItems(GridItemType.Pager))
    {
        Label showAvg = (Label)pagerItem.FindControl("showAggregate");
        showAvg.Text = value; // Set the Label Text
    }
}


And my aspx looks like this:
   <PagerTemplate>
        <asp:Label ID="showAggregate" runat="server" Text="Hi" ></asp:Label>
    </PagerTemplate>
    <Columns>
         . . .                 
        <telerik:GridBoundColumn Aggregate="Avg" DataField="Number" DataType="System.Int32" HeaderText="Number"
            SortExpression="Number" UniqueName="Number">
        </telerik:GridBoundColumn>                  
    </Columns>
</MasterTableView>


Regards,
Shinu.
0
naimish
Top achievements
Rank 1
answered on 02 Oct 2010, 02:22 PM
Hi Shinu,

Sorry for late reply, your given solution helped me to resolve my issue.

Very-very thank you.
Tags
Grid
Asked by
naimish
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
naimish
Top achievements
Rank 1
Share this question
or