Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all articles
Browse latest Browse all 7205

How to create labels instead of textboxes for readonly fields

$
0
0

When the ASPxGridView is in Edit mode, sometimes it is required to mark some fields as readonly. Unfortunately, the ReadOnly state might confuse people, because a readonly editor behaves as a regular editor, but it cannot be edited. It is useful to emphasize the readonly editor by customizing its ReadOnlyStyle property (for example, you can adjust a control's background color).

There are other scenarios to emphasize readonly editors. For example, you can replace the ASPxTextBox (created by the ASPxGridView) with the ASPxLabel placed in the EditItemTemplate. This example demonstrates how to achieve this functionality.
Also, the example demonstrates how to create the EditItem template and the InsertItem template.

The main idea is the following:
1. The edit button is replaced with a custom command button;
2. When the custom button is clicked, some state is written to the ASPxHiddenField;
3. On the server side, the EditItemTemplate property is used depending on the state value.

P.S. In the sample, the EditCellStyle is used to make readonly fields look like regular data cells.

Question Comments

Added By: Bansal at: 6/30/2016 3:02:58 AM    Hi,

Does the same solution work in batch edit mode. I have make the row editable on rowclick client side event. But the lable shows black space as value in place of the actual value.Added By: Mike (DevExpress Support) at: 6/30/2016 5:07:45 AM    

Hello,

I've created a separate ticket on your behalf (T398270: ASPxGridView / E2535 - How to create labels instead of textboxes for readonly fields in Batch Edit Mode). It has been placed in our processing queue and will be answered shortly.


Viewing all articles
Browse latest Browse all 7205

Trending Articles