Currencymanager and finding underlying record i DB: "* If you need to current underlying DataRow, then yes you can get it from
the CurrencyManager, but the 'underlying row' is always a DataRowView (even
when bound to DataTable), from the DataRowView you can get the DataRow; eg:
' using the same DataSource as the one you used for binding
Dim cm As CurrencyManager = DirectCast(BindingContext(DvSpare),
CurrencyManager)
' if you want to be safe, you could also use:
Dim cm As CurrencyManager = DirectCast(BindingContext(dgSpare.DataSource,
dgSpare.DataMember), CurrencyManager)
' then you can get the current DataRowView:
Dim drv As DataRowView = DirectCast(cm.Current, DataRowView)
' from the DataRowView you can get the DataRow:
Dim dr as DataRow = drv.Row
* On the other hand, if you bind to a DataView, then the DataGrid indexes
are the same as the DataView, so you could simply use:
Dim drv As DataRowView = DvSpare(DgSpare.CurrentRowIndex)
Dim dr As DataRow = drv.Row
"
Wednesday, March 21, 2007
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment