By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,375 Members | 1,390 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,375 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Nov 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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
"Maria Anthonsen" <ma*****@INGENSPAMstart.no> wrote in message
news:O1**************@TK2MSFTNGP12.phx.gbl...
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

Nov 21 '05 #2

P: n/a
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
"Maria Anthonsen" <ma*****@INGENSPAMstart.no> wrote in message
news:O1**************@TK2MSFTNGP12.phx.gbl...
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

Nov 21 '05 #3

P: n/a
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

"Brad" <ba******@ukcdogs.com>
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
"Maria Anthonsen" <ma*****@INGENSPAMstart.no> wrote in message
news:O1**************@TK2MSFTNGP12.phx.gbl...
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


Nov 21 '05 #4

P: n/a
Thank you very much!!

hug
Maria

"Cor Ligthert" <no************@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
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

"Brad" <ba******@ukcdogs.com>

Nov 21 '05 #5

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

Chris

"Cor Ligthert" <no************@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
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

"Brad" <ba******@ukcdogs.com>
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
"Maria Anthonsen" <ma*****@INGENSPAMstart.no> wrote in message
news:O1**************@TK2MSFTNGP12.phx.gbl...
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



Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.