PC Review


Reply
Thread Tools Rate Thread

bindingsource_addingnew event for creating default values

 
 
schlagenhauf@web.de
Guest
Posts: n/a
 
      11th Aug 2005
Hello Group,

being relatively new to ADO.NET (and using whidbey nonetheless)
seemingly strange things continue to happen in my app. Most of them are
dealt with by reading more about .net, but this one keeps bugging me.

Here's the story.

I'm calling a form from my main form (newform.show) and tell it that it
should create a new record (newform.mytablebindingsource.addnew).

In the Load Event in the new form, I fill my dataset by using a
parameterized query like
myTableTableAdapter.FillByPKey(myDataset.myTable,1)

Then I use the adding_new event as follows:

Private Sub BeratungenBindingSource_AddingNew(ByVal sender As
System.Object, ByVal e As System.ComponentModel.AddingNewEventArgs)
Handles myTableBindingSource.AddingNew
Dim bSrc As BindingSource = CType(sender, BindingSource)
Dim aView As Data.DataView = CType(bSrc.List, Data.DataView)
If (Not aView Is Nothing) Then
Dim aDrv As Data.DataRowView = CType(aView.AddNew,
Data.DataRowView)
If (Not aDrv Is Nothing) Then
Dim aRow As myDataSet.myTableRow = CType(aDrv.Row,
myDataSet.myTableRow)
aRow.aFKey = 1
aRow.bFKey = 10
e.NewObject = berDrv
bSrc.MoveLast()
End If
End If
End Sub

The idea is to end up in this form with all the Foreign Keys correctly
set. It works out beautifuly when a record already exists, but it won't
work when the binding source is empty - dataview.addnew does not seem
to work in this setting. I don't want to use EndEdit here, because the
row should be completed by the user.

Any guidance is welcome.


Thanks,

Jan.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Table fields:- Setting default values to be based on other field values Rob W Microsoft Access 3 20th Feb 2008 08:51 PM
Creating default values in Excel Dipali.R.Amin@gmail.com Microsoft Excel Programming 1 18th Oct 2006 04:29 PM
building routine to iterate through all event arg values for given event astro Microsoft VB .NET 2 16th Nov 2005 12:54 PM
Creating default values based on prior inputs to a form =?Utf-8?B?QmVsbA==?= Microsoft Access Forms 4 10th Aug 2005 12:26 PM
Default values in .Default user Shell Folders ? Michel S. Windows XP Help 2 19th Jul 2005 07:52 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:58 AM.