PDA

Click to See Complete Forum and Search --> : DataGrid - prohibiting addition of records


BryanJ
Jun 5th, 2002, 09:44 PM
I have a datagrid which is bound to a DataTable.

I would like the user to be able to edit the data in the grid but not be able to add a new record.

If I set the ReadOnly property to false I see that the Grid adds an extra row at the end for record addition.


How does one prevent this extra row. Is there some method to prevent additions to the DataTable.

wolfofthenorth
Jun 5th, 2002, 10:13 PM
You could check to see if RowState = DataRowState.Modified and then update only with those rows.

I "think" something like this might work. :rolleyes:

myDataAdapter.Update(myTable.GetChanges(DataRowState.Modified).Select)

:D

deanh
Jul 4th, 2002, 10:43 PM
Give this a try:

Instead of binding to the datatable directly use a dataview which has an allownew property you can change to false.

BryanJ
Jul 5th, 2002, 10:08 AM
I used the defaultDataview and the allownew property, and it worked great.

Thanks once again for all your help.