Stop deleting a Row in the Changing event within a DataGrid

B

Benedikt Eckhard

Hi!

I wan't to prevent a user to delete some Rows showed in a DataGrid.

I registered for the DataTable.RowDeleting event and tried to throw an
exception when deleting occours but is forbidden(as proposed in the msdn).

Problem: Nobody catches the error, so an application Exception gets shown to
the user. How can I catch the exception or prevent deleting a row in an
other way?

Thanks in advance

Benedikt
 
R

Rajesh Patel

yes, if you are using datatable/dataview as a datasource of grid.

you can make

dataview.allowdelete = false. or
datatable.defaultview.allowdelete = false

that will prevent to delete a row from datagrid.

Rajesh Patel
 
B

Benedikt Eckhard

thanks for the answer!

I don't want to prevent deleting generally, but based on some conditions. so
using the data view isn't really a good solution for me.

benedikt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top