DataGrid control contains GetChanges() method to get a DataSet of rows that
have changed.
I would like to write a method GetSelectedRows() that returns a DataSet of
selected rows (may be multiple rows). I tried to do this by extending the
DataGrid control and writing the following method:
public DataSet GetSelectedRows()
{
...
CurrencyManager cm = (CurrencyManager)BindingContext[myGrid1.DataSource,
myGrid1.DataMember];
DataRow dR = ((DataView)myGrid1.DataSource).Table.Rows[cm.Position];
...
}
I have two issues with this code:
1) Even when multiple rows are selected, only one row is returned. How can
I get a collection of selected rows?
2) This works only if the data in the DataGrid is not sorted. If I first
sort the table by any column and then select a row, say second one, DataRow
returned corresponds to the row that was in second position before sorting,
and not after sorting. Thus a row that is not selected is returned.
Thanks for help in advance.
CSI
Sn - 31 Mar 2005 16:14 GMT
Actually DataGrid does not have GetChanges() method but the DataSet class
does that gives a set of changed rows.
Sorry for the confusion.
I am still looking forward to some help on this.
Thanks,
Siva
> DataGrid control contains GetChanges() method to get a DataSet of rows
> that have changed.
[quoted text clipped - 26 lines]
>
> CSI