Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Rebinding Windows form controls
Message
De
12/05/2008 14:48:15
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Titre:
Rebinding Windows form controls
Versions des environnements
Environment:
C# 3.0
OS:
Windows Server 2003
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01316469
Message ID:
01316469
Vues:
59
Hi,

I have a windows Form that I call to insert new records in Table. I expected the following code in the form constructor to do the work:

public VehicleNewForm()
{
this.oVehicle = (vehicle)this.RegisterBizObj(new vehicle());
InitializeComponent();
this.oVehicle.NewRow();
}

But it doesn’t.

First of all I get the typical error:
“Object reference not set to an instance of an object”

Which I can get rid of if I hydrate my object before calling the NewRow method. This doesn’t make sense to me as I can call the NewRow method a web form and works fine. What I am doing wrong here ?, because I suspect that this is not the real solution.

Once I add the method to hydrate the object, my call to the NewRow method works fine and I have my object with the current row pointing to my new record. But the form is showing the first record so I thought that I need to rebind all the controls in the form in order to get the blank record so I added the line:

this.oVehicle.CallStateChange(mmBusinessState.Bind);

After that I still get the form with the first row data. I can inspect my DataSet and it shows the new row inserted with the corresponding auto generated ID column and the reminding columns as nulls (as it should be). Also if I ask for any specific column using the entity object it has the proper value (null).

So my second question is how I get the form synchronized with the business object again.

Thanks in advance for your advice.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform