I have a database application, part of which requires multiple inserts (up to 50 records) from a single form. I have considered using a datagrid to allow the user to update the database. The datagrid has 6 columns, 4 of which are prepopulated from a look up table in the database.
The datagrid is bound to a datatable which has two columns of null values. It is these columns which the user needs to edit. So far so good. Except I cannot find a way to stop the user adding rows to the end of the datagrid. Setting ColumnStyles to read only is only effective post creation of a new row.
I would br grateful for some pointers as to how I can stop users adding new datagrid rows or alternatively how I could limit the number of rows in a datagrid. (I am using VS 2003 C'#)
Many Thanks in advance
Loading
Alec CohenPosted Dec 15, 2005, 6:34 AM
Used the dataview.
Many Thanks
Andrzej WegierskiPosted Dec 15, 2005, 2:40 AM
- bind dataview instead of datatable and modify AllowNew property
- inherit Your datagrid, create Your own property View to see internal DataView independently of kind of binded object (DataSet, DataTable, DataView):
public DataView Wiew
{
get
{
if(this.ListManager==null || this.ListManager.List==null) return null;
return this.ListManager.List as DataView;
}
}
Not tested