Home All Groups Group Topic Archive Search About
Author
20 Mar 2006 9:50 PM
phonl
In ADO2, how would I find the position of "x" in:

myDataSet.Tables("myTable").Rows(x).Item("myField") = "NewValue"

I want to manipulate some data in the current row in my dataset, but it
seems that I have to know the index of the row that my dataset is at.  How
do I find the index of the current row?

Author
21 Mar 2006 2:11 AM
Kevin Yu [MSFT]
Hi phonl,

Actually, you needn't get the position of it. If you already have the
BindingSource object, the BindingSource.Current property returns the
current DataRow object. Manipulate on that object to set the new value. If
you really need to get the position, BindingSource.Position property will
do the trick.

Hope that helps.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
Author
21 Mar 2006 1:51 PM
phonl
Thank you Kevin; that works great.  I used the DataRowView object of
BindingSource.Current.

Another question on this topic; If I decided not to use the BindingSource
and just go with a TableAdaper and DataSet, is there a way to know the
position of x?

myDataSet.Tables("myTable").Rows(x).Item("myField") = "NewValue"




Show quoteHide quote
"Kevin Yu [MSFT]" <v-k***@online.microsoft.com> wrote in message
news:8KYqAzITGHA.4824@TK2MSFTNGXA03.phx.gbl...
> Hi phonl,
>
> Actually, you needn't get the position of it. If you already have the
> BindingSource object, the BindingSource.Current property returns the
> current DataRow object. Manipulate on that object to set the new value. If
> you really need to get the position, BindingSource.Position property will
> do the trick.
>
> Hope that helps.
>
> Kevin Yu
> =======
> "This posting is provided "AS IS" with no warranties, and confers no
> rights."
>
Author
21 Mar 2006 2:13 PM
phonl
Thank you Kevin; that works great.  I used the DataRowView object of
BindingSource.Current.

Another question on this topic; If I decided not to use the BindingSource
and just go with a DataAdaper and DataSet, is there a way to know the
position of x?

myDataSet.Tables("myTable").Rows(x).Item("myField") = "NewValue"


Show quoteHide quote
"Kevin Yu [MSFT]" <v-k***@online.microsoft.com> wrote in message
news:8KYqAzITGHA.4824@TK2MSFTNGXA03.phx.gbl...
> Hi phonl,
>
> Actually, you needn't get the position of it. If you already have the
> BindingSource object, the BindingSource.Current property returns the
> current DataRow object. Manipulate on that object to set the new value. If
> you really need to get the position, BindingSource.Position property will
> do the trick.
>
> Hope that helps.
>
> Kevin Yu
> =======
> "This posting is provided "AS IS" with no warranties, and confers no
> rights."
>
Author
22 Mar 2006 6:55 AM
Kevin Yu [MSFT]
Hi phonl,

Yes, you can still get that current row with CurrencyManager. If you are
binding the DataSet to a DataGrid like:

dataGrid1.DataSource = DataSet1.Tables[0];

You can get the CurrencyManager like

CurrencyManager cm =
(CurrencyManager)dataGrid1.BindingContext[DataSet1.Tables[0]);

cm.Current is that DataRowView object and cm.Position is the position of
currencly selected row. Actually, BindingSource is getting that information
from the CurrencyManager. HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
Author
22 Mar 2006 7:52 PM
phonl
Thanks again Kevin.  I was able to make it work from your example.


Show quoteHide quote
"Kevin Yu [MSFT]" <v-k***@online.microsoft.com> wrote in message
news:iEzkw2XTGHA.5524@TK2MSFTNGXA03.phx.gbl...
> Hi phonl,
>
> Yes, you can still get that current row with CurrencyManager. If you are
> binding the DataSet to a DataGrid like:
>
> dataGrid1.DataSource = DataSet1.Tables[0];
>
> You can get the CurrencyManager like
>
> CurrencyManager cm =
> (CurrencyManager)dataGrid1.BindingContext[DataSet1.Tables[0]);
>
> cm.Current is that DataRowView object and cm.Position is the position of
> currencly selected row. Actually, BindingSource is getting that
> information
> from the CurrencyManager. HTH.
>
> Kevin Yu
> =======
> "This posting is provided "AS IS" with no warranties, and confers no
> rights."
>
Author
23 Mar 2006 2:31 AM
Kevin Yu [MSFT]
You're welcome.

Thanks for sharing your experience with all the people here. If you have
any questions, please feel free to post them in the community.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."