Getting selected Rows counts

Hi, How do i get the selected Rows count for grid databound grid? i''ve tried "gridatabound.selections.count", but it will only return 1 no matter how many rows i selected. Thanks in advance :)

4 Replies

ST stanleyj Syncfusion Team February 23, 2006 03:15 PM UTC

Hi Wye Jin, Try this: this.gridDataBoundGrid1.Selections.Ranges.ActiveRange.Height Best regards, Stanley


AD Administrator Syncfusion Team February 24, 2006 01:54 AM UTC

Hi stanley, Thanks for saving my day again. It works perfectly :)


UN Unknown Syncfusion Team August 2, 2017 02:33 PM UTC

A little late for a response, but for future reference if you allow multiple range selection, you'll need to loop through all Ranges, and sum the Height of each.

If you select rows 1-10 and then 15-17, your count will only be 3 with ActiveRange.Height.



MG Mohanraj Gunasekaran Syncfusion Team August 3, 2017 09:26 AM UTC

Hi Chris, 

Thanks for your update. 

Yes, you were right. if you want the selection count for multiple range selection, you can iterate the ranges and calculate the height for all Ranges. Here, I have shared the code part to calculate the selection count. 

Code example 

int selectionCount = 0; 
foreach (GridRangeInfo range in this.gridDataBoundGrid1.Selections.Ranges) 
{ 
    selectionCount += range.Height; 
} 
 

Regards, 
Mohanraj G 


Loader.
Up arrow icon