Sceppa's ADO.Net Bible Question

G

Guest

In Chap 13 David shows you how to bind a second form to the same data source
by passing the CurrencyManager as an arg to the EditDetail Method of the
second form:

Public Sub EditDetail(byval CM as CurrencyManager)

drvDetail = Ctype(CM.Current, DataRowView)
vueDetail = drvDetail.DataView

Me.BindingContext(vueDetail).Position = CM.Position

I have run into a problem that I am really stumped on - if the CM passed in
has no Current position, which would be the case if you were possibly adding
the first row to a child table, then you can not get at the DataView.

Is there some other way to get to the DataView?

This is also a problem I am faced with when I have a DataView of a parent
table and use the following code to bind children where the DataMember is a
relationship:

With grdGuestContacts
.DataSource = oParentsView
.DataMember = "tblGueststblGuestContacts"
CM = CType(Me.BindingContext(.DataSource, .DataMember), CurrencyManager)
end with

If the child table has no records there is no way (that I know of) to get at
the DataView in order to disable AllowNew because CM.Current is NOT on a
current record.

Any ideas?
 
G

Guest

Why is it that no matter how much time you spend trying to figure a problem
out that within minutes of posting it you find the answer?

If the CurrencyManager has no Current record than the DataView can be
obtained by casting its List object as:

dim oView as dataview = ctype(CM.List, DataView)
 
D

David Sceppa

I think it's a corollary to Murphy's Law. ;-)

No worries. It happens all the time.

David Sceppa
Microsoft
This posting is provided "AS IS" with no warranties,
and confers no rights. You assume all risk for your use.
© 2005 Microsoft Corporation. All rights reserved.
 
J

Jay Pondy

David

Just wanted to congratulate and compliment you on a truly awesome book
- by far the most used in my extensive library - excellent writing,
layout and solutions for real problems. Keep up the great work as I
am really looking forward to wearing out version 2.0 as well.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top