Sometimes it is necessary to make a WebGrid cell read-only based on some condition. This article shows how to set a cell as read-only, which can be done on the client-side or server-side.
To do this on the server, set the AllowEditing property of the cell to "AllowEditing.No". On the client, the cell needs to be disabled using the BeforeEnterEditMode client-side event handler.
Server-Side:
In the InitializeRow event, set AllowEditing property to "AllowEditing.No" after checking the condition. In this example, updates are forbidden for cells in the fourth column if the value is already greater than 5000:
private void UltraWebGrid1_InitializeRow(object sender, Infragistics.WebUI.UltraWebGrid.RowEventArgs e)
{
if ((int) e.Row.Cells[3].Value > 5000)
{
e.Row.Cells[3].AllowEditing = Infragistics.WebUI.UltraWebGrid.AllowEditing.No;
}
Sunday, September 21, 2008
Make a WebGrid cell read-only in certain conditions
Posted by Suryan at 12:00 PM
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment