how to configure a DataGrid so that only some columns are editable in Edit mode

C

Cahoo

I have been following the MSDN walkthrough "Using a DataGrid Web
Control to Read and Write Data" in order to display an editable
DataGrid. This has been working great - I am pleased with how simple
it all is.

The only thing that I haven't been able to do is select which columns
are editable when the user clicks the Edit button in a row. My table
has a primary key made up of 3 columns. I don't want the user to be
able to edit these 3 columns. Is there any way for me to configure
the data grid so that only some of the columns are editable?

Any ideas are greatly appreciated (and thanks also for all the help
I've gotten by searching this group so far)!
 
T

Travis Murray

Right-click the DataGrid
Click "Property Builder"
Click "Columns"
If the checkbox at the top is checked (something about "Automatically add
columns at run time"), uncheck it
In the Available Columns list, choose the ones you want
In the Selected Columns list, click your primary key columns (one at a time)
Click the "Read Only" check box

This was OTTOMH, so some of the names might not be exactly right. Hope this
helps.

Travis Murray
MCSD, MCT
Artiem Consulting, Inc.
http://www.artiem.com
 
S

Scott M.

Right click the grid and choose Property Builder, then look at the columns
for your grid. Do you have your columns set up as Template Columns? If
not, change each column into a Template Column via the hyperlink in the
dialog box at the bottom. Exit from the Property Builder.

Now, right click the grid and choose Edit Template Columns. For the
column(s) that you DON'T want people to be able to edit, enter into the Edit
Template of that column. Change the control that is being used for editing
(probably a textbox or checkbox) by simply changing it's enabled property or
locked property accordingly. You could also use a different control
altogether, like a label to display the data.
 
A

-Alex

I'm a bit new at this....

I have a simple form with a datagrid. I right click the grid and do not
have a selection for Property Builder.

What am I missing?

-Alex
 
S

Scott M.

Ah, sorry. I thought you were referring to a WebForm DataGrid, you must be
building a Windows Applicaiton and using the Windows.Forms.DataGrid.

I don't have the answer for you in that case. :(
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top