Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
GridView save nullable integer
Message
From
17/08/2007 10:17:02
 
 
To
All
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Title:
GridView save nullable integer
Miscellaneous
Thread ID:
01248755
Message ID:
01248755
Views:
73
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
...
Next
Reply
Map
View

Click here to load this message in the networking platform