Home > Ask the Microsoft .Net Development Experts > Visual Studio .NET Questions & Answers > Changing a datagrid column to read-only=false based on variable
Ask The Win Development Expert: Questions & Answers
EMAIL THIS

Changing a datagrid column to read-only=false based on variable

Berni McCoy EXPERT RESPONSE FROM: Berni McCoy

Pose a Question
Other Win Development Categories
Meet all Win Development Experts
Become an Expert for this site


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


>
QUESTION POSED ON: 01 August 2004
I have a DataTable that is bound to a datagrid. Is there a way to dynamically change a column in a datagrid from read-only=true to read-only=false when in edit mode based on a variable that has been obtained from a different table? I am using Visual Studio .NET 2003 with Visual Basic and ASP.NET.

>
The best way to do this is to enable templates on your DataGrid. You can do this by right-clicking on your DataGrid and opening the Property Builder. In the Property Builder, select the Columns item in the list view and change or add Template columns to your DataGrid. When you've added all your template columns, close the Property Builder and right click the DataGrid in your page. Select Edit Template > and select the column you want to edit. Now you can add controls to any of the modes for that column. In your case, you'll probably want a TextBox in the Edit Template. Once you add the TextBox, go to it's property view and select the (DataBindings) property by clicking the [...] button in its property field. This will open the DataBindings form for the TextBox. Select the ReadOnly field from the BindableProperties list and then select the "Custom binding expression" option. You'll want to create an expression that uses the variable you obtained from a different table. For more info on creating custom binding expressions, refer to "Data-Binding Expressions for Web Forms Pages" topic in MSDN.


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
Visual Studio .NET
Load a DSL domain model instance file programmatically
Calling via command prompt from ASP.NET
On line-by-line analysis in VS .NET
Best approach for merging text files using arrays
Descriptions of symbols in the class view of a .NET solution
What's the best approach for enumerating network resources?
How to enable a line-by-line code walkthrough
Changing a C++ Makefile project to a Utility project
How can I configure Visual Studio.NET 2002 to use the .NET Framework 1.1?
No extensibility folders

Visual Studio .NET
Load a DSL domain model instance file programmatically
Best approach for merging text files using arrays
Descriptions of symbols in the class view of a .NET solution
What's the best approach for enumerating network resources?
How to enable a line-by-line code walkthrough
Changing a C++ Makefile project to a Utility project
How can I configure Visual Studio.NET 2002 to use the .NET Framework 1.1?
No extensibility folders
Can I use VS.NET on a server that's not upgraded to .NET Framework?
Resizing controls on a form

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice



Windows Development - White Papers, News and Expert Advice
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2000 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts