prevent user from adding a new record to a datagrid/dataset

  • Thread starter Thread starter Maria Anthonsen
  • Start date Start date
M

Maria Anthonsen

I have filled a datagrid with data from a dataset. The dataset was filled
with a dataadapter - and I used the wizard to create insert, update, delete
commands.

I would like to prevent the user from adding a new record in the datagrid,
but still be able to change/delete data - is this possible??

Maria
 
you need to associate the datatable you are looking at with a dataview. set
the dataview.allownew property to false. Then bind the dataview to datagrid

dim DV as new DataView
DV.Table = DataSet.Table(0) 'I think that's the right way to get the table
DV.AllowNew = False
DataGrid.DataSource = DV

Enjoy
Chris
 
When doing your Query through the wizard, after building your query click on
the button "Advanced Options". Uncheck the box that says Generate Insert,
Update and Delete statements. This will prevent any of these functions to
be run against the dataset.

Hope this helps.

Brad
 
Brad,

In my opinion does not do as Maria asked, the + in the datagrid stays,
therefore is needed as Chris wrote or something as
\\\
ds.tables(0).defaultview.allownew = false
///
I hope that helps?

Cor
 
Thanks Cor, I had wondered how to do the same concept for a multi-table
dataset. Thanks again for enlightenment.

Chris
 
Back
Top