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)
{
...
if (e.NewValues["inventory_control"] == null || (string)e.NewValues["inventory_control"] == String.Empty)
{
e.NewValues["inventory_control"] = System.DBNull.Value;
}
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
...