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

Getting Multi Selected Row problem

Hi,

I''m having problems getting the selected row index for 2 different cases.

First the Continous Multiselections of rows, which i use the following codes to get the first column''s cell value, please refer to "ContinousSelections.JPG" for a better understanding of my situation:

int rowCount = dgDocument.Selections.Ranges.ActiveRange.Height;
if (rowCount > 0)
{
ArrayList arDeleteDocumentNo = new ArrayList();
foreach (GridRangeInfo r in this.dgDocument.Selections.Ranges)
{
for (int row = r.Top; row <= r.Bottom; row++)
{
string delDocumentNo = this.dgDocument[row, 1].CellValue.ToString().Trim();
arDeleteDocumentNo.Add(delDocumentNo);
}
}

Then the NonContinous Multiselections of rows, which i use the following codes to get the first column''s cell value, please refer to "NoNContinousSelections.JPG" for a better understanding of my situation:

int rowCount = dgDocument.Selections.GetSelectedRows(true, true).Count;
if (rowCount > 0)
{
ArrayList arDeleteDocumentNo = new ArrayList();
foreach (GridRangeInfo r in this.dgDocument.Selections.GetSelectedRows(true, true))
{
for (int row = r.Top; row <= r.Bottom; row++)
{
string delDocumentNo = this.dgDocument[row, 1].CellValue.ToString().Trim();
arDeleteDocumentNo.Add(delDocumentNo);
}
}

Is there any way i could get the cellvalues i want combining the 2 types of multiselections approach i''ve attached with this post?

Please message me if my question is not clear enough or if you have any doubts about my post.
Thanks in advance. :)

MultiSelectionsProblem.zip

5 Replies

AD Administrator Syncfusion Team August 22, 2006 09:25 AM UTC

I''m sorry that i missed out a very important information. I''m using GridDataBound. :)


AD Administrator Syncfusion Team August 22, 2006 11:00 AM UTC

Hi Wye,

You can call the GetSelectedRows() method to get the Selected rows in a grid. Please refer the attached sample for more details.

Here is a sample.
http://www.syncfusion.com/Support/user/uploads/Selection_b6f085dc.zip

Let me know if this helps.
Regards,
Haneef


AD Administrator Syncfusion Team August 23, 2006 03:47 AM UTC

Hi Haneef,
thanks for replying :)
I''m using GetSelectedRows(true, true) now, and i''m using SelectionMode.MultiExtended now. if i hold shift and Arbitrary Select few records. I''ll only get one result(I should have get multiple selected records).

I tried using MultiSimple selectionMode, it works, but it doesn''t suite my User Interface flow.

I''ve attached the sample project to my situtations, i hope this help you to understand my problems.

Thanks in advance :)

WindowsApplication215.zip


AD Administrator Syncfusion Team August 23, 2006 06:06 AM UTC

Hi Wye,

The reason is that GetSelectedRows method returns the GridRangeInfoList object. You are using the Count property of GridRangeInfoList to get the no of the selected range in a grid [Not a selected rows]. If you want to get the no. of selected rows in a grid , try this code

//==========Get Delete Marker No==================
int RowCount = 0 ;
ArrayList arDeleteKey = new ArrayList();
foreach (GridRangeInfo r in this.dg.Selections.GetSelectedRows(true, true))
{
for (int row = r.Top; row <= r.Bottom; row++)
{
string deletekey = this.dg[row, 1].CellValue.ToString().Trim();
arDeleteKey.Add(deletekey);
RowCount++;
}
}
//==============================================

Console.WriteLine("Number of Selected rows in a Grid : " + rowCount);

Let me know if this helps.
Best Regards,
Haneef


AD Administrator Syncfusion Team August 24, 2006 03:19 AM UTC

Thanks a lot Haneef.. It works.. :)

Loader.
Live Chat Icon For mobile
Up arrow icon