473,396 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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
5 1489
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Chumley the Walrus | last post by:
IN my code behind .vb page for a delete records script (this also does a deletion confirmation with a javascript popup, this gets called on my front .aspx page with the datagrid), I'm not sure if...
1
by: Job Lot | last post by:
In a multi-user environment, how would I prevent users from adding Orders with identical OrderID. For instance I have following tables in my database Order ================== OrderID Identity...
2
by: Clayton Hamilton | last post by:
I have a DataGrid on a webform bound to a Datasource and can successfully use <ItemTemplate> to create edit/update/cancel functionality for user maintenance of data. I use separate logic to delete...
6
by: anoj | last post by:
Hi All i need to prevent multiple logins from the same user at the same time. what is the best way to do this . How can i detect if a user closes the browser window without logging out so tht...
1
by: Brian | last post by:
Hello - Is there a way to prevent the user from creating a blank row at the bottom of a datagrid? I want a read only grid that allows the user to view data but not select specific cells or...
2
by: Tor Inge Rislaa | last post by:
Prevent Adding new records in DataGrid Hi I have a DataGrid that I want to open for editing but the user should not be able to add new records. When I set the ReadOnly = False it is possible...
12
by: Aaron Smith | last post by:
What is the best way to handle data in a multiple user environment? We have forms that will allow users to add edit and delete data from a table on SQL server. The data could be edited on multiple...
4
by: Rich | last post by:
I fill a dataset like this: dim da As New SqlDataAdapter, ds As New Dataset, conn As New SqlConnection .... da.Fill(ds, "tbl1") datagrid1.DataSource = ds datagrid1.DataMember = "tbl1" When...
5
by: Sharon | last post by:
I have a DataGrid on my Form, and I wish to disable any cell editing. For example; when the user clicks on a cell, the cell become editable by changing its color to gray and context menu is shown...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.