Solved

Configure a DataGrid for limited user access

Posted on 2007-04-04
2
241 Views
Last Modified: 2010-04-23
Hi,

I have a datagrid that is bound to a datatable in code and I am using DataGridTableStyles to format the grid just the way I want it to look. I don't want the user to be able to add any new rows so I set the dagatgrid.ReadOnly property to TRUE. However, there is one column of rows that I do want the user to be able to change. In this case I was thinking the user could type a new number in a particular cell and then click on a button to store the changes back to the original database table.

So, is there any way to prevent the user from adding rows to a datagrid and keep the entire datagrid as Read-)nly except for one column?

Thanks,
Charlie
0
Comment
Question by:charlieb01
  • 2
2 Comments
 
LVL 5

Accepted Solution

by:
mytonytiger earned 500 total points
ID: 18853959
I assume you are using VS 2003:

To prevent the users from adding rows, you have to set it in the datatable being used as a datasource.
An example is:  

Dim ds as new dataset
'---------------------
'Fill dataset here
'---------------------

'Now turn off the new row
ds.tables(0).DefaultView.AllowNew = False
datagrid1.datasource = ds.tables(0)

0
 
LVL 5

Expert Comment

by:mytonytiger
ID: 18853969
The Second part of your question is about locking down all but one column:

You can set each individual column of the datatable as readonly.

ds.tables(0).Columns(0).readonly = True
ds.tables(0).Columns(1).readonly = True
ds.tables(0).Columns(2).readonly = True
'etc....
ds.tables(0).Columns(3).readonly = false ' This one is editable.



Hope that helps
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Get the selected ValueMember of Combobox 5 31
SQL LINE CONTINUATION ISSUE 12 33
Error handling in asp.net site 5 28
VB.Net WebRequest Code from JSON curl 9 13
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question