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

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
 
C

Chris

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
 
B

Brad

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
 
C

Cor Ligthert

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
 
C

Chris, Master of All Things Insignificant

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

Chris
 

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