We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Get selected rows/cells in griddataboundgrid


Hi,

I am using GridDataBoundGrid and need to get the contents of the selected rows. I am looking something like the DataGridViewSelectedRowCollection in windows forms.

I am using the MultiExtended selection mode as below:

_aggregateGrid.ListBoxSelectionMode = SelectionMode.MultiExtended; [so that whole rows are selected instead of individual cells]

If the user selects 2 rows, how do I get the contents of the selected rows(I need to get the cell values as well). Also I need to find out which cell was selected first.

I tried using :

GridRangeInfoList rangeList = new GridRangeInfoList();
_aggregateGrid.Selections.GetSelectedRanges(out rangeList, true);
if (rangeList.Count > 0)
{
foreach (GridRangeInfo range in rangeList)
{
GridStyleInfo[] info = _aggregateGrid.Model.GetCellsInfo(range);

but this returns info as null.

Thanks,
Tanmay

1 Reply

LS Lingaraj S Syncfusion Team May 23, 2009 06:47 AM UTC

Hi Tanmay,

Thank you for your interest in Syncfusion product.

If you want to get the selected cells in GridDataBoundControl. Please try using GridRangeInfo properties to acheive this behaviour.

Please refer the code below:

GridRangeInfoList list;
if(this.gridDataBoundGrid1.Selections.GetSelectedRanges(out list, true))
{
foreach(GridRangeInfo range in list)
{
List range = new List();
for(int i = range.Top; i <= range.Bottom; i++)
for(int j= range.Left; j <= range.Right; j++)
range.Add(GridRangeInfo.Cell(i,j));
}
}


Please let me know if it helps.

Regards,
Lingaraj S.

Loader.
Live Chat Icon For mobile
Up arrow icon