I have a databoundGrid (220.127.116.11) with an unbound column. I have buttons in this column. When the button is clicked I am setting some values in the bound columns of the same row. It works fine if I start editing the new row in a bound column. But if I click the button (unbound column) my code (grid[curRow, someCol].CellValue = "xyz") is failing. How do I let the binder know that "Go ahead and add a new row".
You can see the same effect in the GridMultiHeader sample.
1. Run the sample.
2. Highlite "WILMK" and "WOLZA" rows and hit delete key.
3. Without clicking on any other cells, click on the drop down calendar in the unbound cell and pick a date. You will see the date now.
4. Click on the checkbox above the drop down.
5. The date disappears from the last row.
6. But if you type abc in the last row customer id and then select a date, it seems to work.
Any ideas on how to add this new row before editing the bound column?
ADAdministrator Syncfusion Team February 28, 2004 01:56 AM
In the sample, the unbound column values are stored in a hashtable using CustomerID as the lookup key. So, when you enter the unbound value in the AddNew row without adding a CUstomerID value, there is no key for the hashtable, so the value does not get saved.
I think you can use CurrentCellStartEditing to add a new row directly to the DataTable. Normally, if you have a primary key column, calling DataTable.NewRow would populate the primary key for you. But the NorthWind database does not auto populate customerID, so you would either do it yourself, or not let the user leave the row (RowLeave event) until he provided the value.
Here is code that worked for me in the sample. It populates the customerID column. One other thing for this NorthWind Database is the CustomerName has a non-empty constraint on it. So, to avoid this constraint exception, the code puts a blank into that field as well.