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

[Solved] Count for Filtered Grid

3 Answers 100 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 20 Jul 2009, 10:58 PM
How do I get the count of records in code behind (C#) from a radgrid after applying a filter?

Thank you,
Dave

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 21 Jul 2009, 06:26 AM
Hello David,

You can check if the FilterCommand is fired and set a boolean variable. Then in the PreRender event of the grid check if the boolean variable is set and retrieve the count of the items in the grid. The following examople should help you understand better:
c#:
bool filteredItems = false
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
 { 
   if(e.CommandName == RadGrid.FilterCommandName) 
    { 
       filteredItems = true
    } 
 } 
 
 protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
       if(filteredItems == true
            int count = RadGrid1.Items.Count; 
    } 

Thanks
Princy.
0
David
Top achievements
Rank 1
answered on 21 Jul 2009, 04:15 PM
How about with paging on? 

RadGrid1.Items.Count 
The above will only get what is being displayed in the grid currently.

Thanks Princy,
Dave
0
David
Top achievements
Rank 1
answered on 21 Jul 2009, 04:29 PM
Found the solution (I looked forever and couldn't find it before!)
Count of filtered items with paging

Thank you for your time,
Dave






Tags
Grid
Asked by
David
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
David
Top achievements
Rank 1
Share this question
or