Eric Renken, the Web Master for the Michiana Area .NET Users Group (MADNUG), has shared with me a code-free way to make columns read-only in the new DetailsView control in ASP.NET 2.0 and I wanted to share this cool technique with you.

Here are the steps to set a field in the DetailsView as read-only.

1.      Create a details view and point it to your data source so you can see the columns
2.      Go to the Common DetailsView Tasks and click Edit Fields
3.      In the Selected Fields list, select the Field you would like to make read only
4.      In the Bound Field Properties list scroll down to ReadOnly under Behavior and mark this as True

That is all you need to do, so next time you edit the details it will leave this column as read only.

Just another way that ASP.NET 2.0 will make your life easier as a developer.  To try this and other new controls and techniques introduced in ASP.NET 2.0, visit the Visual Web Developer 2005 Express Edition Beta website!

Happy coding,

Jacob