Click here to Skip to main content
15,936,119 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hello,
I am work in Telerik win form using c#,

I have grid view and i want to add footer which calculate the units as per below sawed.

My code as below.

C#
GridViewSummaryItem summaryItem = new GridViewSummaryItem();
            summaryItem.Name = "Units";
            summaryItem.Aggregate = GridAggregateFunction.Count;

            GridViewSummaryRowItem summaryRowItem = new GridViewSummaryRowItem();
            summaryRowItem.Add(summaryItem);
            this.GridViewWorkInProgress.SummaryRowsTop.Add(summaryRowItem);
            this.GridViewWorkInProgress.SummaryRowsBottom.Add(summaryRowItem);



I t will throws the error of NullReference Exception Unhandled.

give me the solution for that.


Thanks
Posted
Updated 9-Feb-15 20:44pm
v2
Comments
/\jmot 9-Feb-15 5:14am    
debug the code.
and tell in which part it's throwing exception??
dlpanchal 9-Feb-15 5:16am    
summary row item
shows nullreference Exception Unhandled
/\jmot 9-Feb-15 5:21am    
GridViewSummaryRowItem summaryRowItem = new GridViewSummaryRowItem();//this part??
dlpanchal 9-Feb-15 5:23am    
no
this.GridViewWorkInProgress.SummaryRowsTop.Add(summaryRowItem);
here
it will show null for summaryRowItem
Richard Deeming 9-Feb-15 10:15am    
REPOST
You have already posted this question, and received several solutions which you have accepted:
http://www.codeproject.com/Questions/873382/How-Can-I-Add-Footer-In-Gridview[^]

1 solution

CHECK THIS OUT
XML
<telerik:RadGridView x:Name="radGridView2" ShowColumnFooters="True" CanUserInsertRows="True" BorderThickness="0,1,0,1" GridLinesVisibility="None" CanUserFreezeColumns="False" AutoGenerateColumns="False" ItemsSource="{Binding lstOperationProfile}"  ShowGroupPanel="False" IsReadOnly="False">
                           <telerik:RadGridView.Columns>
                               <telerik:GridViewDataColumn IsReadOnly="False" Width="200" Header="OperationID" DataMemberBinding="{Binding Operation}">
                                   <telerik:GridViewColumn.Footer>
                                       <telerik:RadButton x:Name="Add"  Content="AddNewRow" Command="telerikGrid:RadGridViewCommands.BeginInsert" CommandTarget="{Binding ElementName=radGridView1}"  />
                                   </telerik:GridViewColumn.Footer>
                               </telerik:GridViewDataColumn>
                               <telerik:GridViewDataColumn IsReadOnly="False" Width="200" Header="OperationName" DataMemberBinding="{Binding TimeHrs}"   />
                               <telerik:GridViewDataColumn IsReadOnly="False" Width="200" Header="OperationTime" DataMemberBinding="{Binding TimePercen}" />
                               <telerik:GridViewDataColumn IsReadOnly="False" Width="200" Header="LoadOnGensets" DataMemberBinding="{Binding LoadOnGensets}"/>
                               <telerik:GridViewDataColumn IsReadOnly="False" Width="200" Header="Total" DataMemberBinding="{Binding Total}"  />
                           </telerik:RadGridView.Columns>
                       </telerik:RadGridView>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900