• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 252
  • Last Modified:

Configure a DataGrid for limited user access

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
charlieb01
Asked:
charlieb01
  • 2
1 Solution
 
mytonytigerCommented:
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
 
mytonytigerCommented:
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now