Adding new rows to DataGridView UI in DataBound Mode
-
Hi Friends, I have a requirement to add new rows to the DataGridView UI which is bound to a DataTable. The new row added to the UI should get added to the underlying DataSource. I have bound the DataGridView to a DataSource. The DataSource consists of 10 columns out of which only 5 columns were bound to the DataGridView. The other 5 columns which are not bound consists of composite primary key on 2 columns and 3 other columns will not accept null values. I have tried with "DefaultValueNeede" event of the DataGridView to define the default values for the new row. As only 5 columns are bound to the DataGridView, I could supply the default values only to those columns. How would I supply the default values to the rest of the columns which are not bound to the DataGridView? Which event of the DataGridView should be handled in this scenario? An exception is thrown when I tried to commit the new row in the DataGridView UI (by adding a "new new row") to the DataGrid. The exception is that "Required values are not supplied to the new DataRow" which are the composite primary key columns (2) and not null columns (3). Thanks.
Subrahmanyam K
-
Hi Friends, I have a requirement to add new rows to the DataGridView UI which is bound to a DataTable. The new row added to the UI should get added to the underlying DataSource. I have bound the DataGridView to a DataSource. The DataSource consists of 10 columns out of which only 5 columns were bound to the DataGridView. The other 5 columns which are not bound consists of composite primary key on 2 columns and 3 other columns will not accept null values. I have tried with "DefaultValueNeede" event of the DataGridView to define the default values for the new row. As only 5 columns are bound to the DataGridView, I could supply the default values only to those columns. How would I supply the default values to the rest of the columns which are not bound to the DataGridView? Which event of the DataGridView should be handled in this scenario? An exception is thrown when I tried to commit the new row in the DataGridView UI (by adding a "new new row") to the DataGrid. The exception is that "Required values are not supplied to the new DataRow" which are the composite primary key columns (2) and not null columns (3). Thanks.
Subrahmanyam K