Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
GridView save nullable integer
Message
De
17/08/2007 10:17:02
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Titre:
GridView save nullable integer
Divers
Thread ID:
01248755
Message ID:
01248755
Vues:
75
I have a table with nullable integer columns I'm using in a editable mmGridView.

When I update, leaving the integer columns blank, I get an error below.

How can I set these columns to DBNull? Thanks!

This doesn't work:
    protected void gridCountSheet_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
...
        // try setting blank entries to DBNull
        if (e.NewValues["inventory_control"] == null || (string)e.NewValues["inventory_control"] == String.Empty)
        {
            e.NewValues["inventory_control"] = System.DBNull.Value;
        }
       
        // Save the DataSet (the GridView automatically binds back)
        mmSaveDataResult saveResult = this.Save(this.oManualCountSheet, dsManualCountSheet);

...
The error:
Cannot set Column 'inventory_control' to be null. Please use DBNull instead.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: Cannot set Column 'inventory_control' to be null. Please use DBNull instead.

Source Error:

Line 235:
Line 236: // Save the DataSet (the GridView automatically binds back)
Line 237: mmSaveDataResult saveResult = this.Save(this.oManualCountSheet, dsManualCountSheet);
Line 238:
Line 239: if (saveResult == mmSaveDataResult.RulesPassed)

Stack Trace:

[ArgumentException: Cannot set Column 'inventory_control' to be null. Please use DBNull instead.]
System.Data.DataRow.set_Item(DataColumn column, Object value) +1890089
System.Data.DataRow.set_Item(String columnName, Object value) +24
OakLeaf.MM.Main.Web.UI.WebControls.mmGridView.BindBack(DataSet ds, String tableName) +1042
OakLeaf.MM.Main.Web.UI.mmWebBindingStrategyDataGrid.BindData(ImmWebBindingDataGrid mmGrid, mmBusinessObject bizObj, Boolean bindBack, mmBusinessStateChangeEventArgs e) +589
OakLeaf.MM.Main.Web.UI.mmWebBindingStrategyDataGrid.BindData(ImmWebBindingDataGrid mmGrid, mmBaseBusinessObject bizObj, Boolean bindBack, mmBusinessStateChangeEventArgs e) +188
...
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform