This is a migrated thread and some comments may be shown as answers.

Disable Edit Textbox for a column and not the insert textbox

2 Answers 557 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jeremy
Top achievements
Rank 1
Jeremy asked on 12 Apr 2011, 10:01 PM
Hi I am trying to make sure that a column can not be edited but when you insert a new one the textbox is available to create a new row.  I found out how to disable the textbox that is being edited but it also disables the textbox for the insert as well and I dont want that.  Is there a way to only allow for the edit text box to be disabled and not the insert text box?

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 14 Apr 2011, 05:40 AM
Hello Jeremy,

Try the following code to make a column ReadOnly in editmode and editable in insertmode.

C#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
   
   if ((e.Item is GridEditFormItem) && (e.Item.IsInEditMode) && (!e.Item.OwnerTableView.IsItemInserted))
           {
               GridEditableItem item = (GridEditableItem)e.Item;
               TextBox txtbx = (TextBox)item["CoumnUniqueName"].Controls[0];
               txtbx.Enabled = false;
           }
    }

Thanks,
Shinu.
0
Jeremy
Top achievements
Rank 1
answered on 14 Apr 2011, 02:47 PM
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    if ((e.Item is GridEditFormItem) && (e.Item.IsInEditMode) && (!e.Item.OwnerTableView.IsItemInserted))
    {
        GridEditableItem item = (GridEditableItem)e.Item;
        TextBox txtbx = (TextBox)item["CoumnUniqueName"].Controls[0];
        txtbx.Enabled = false;
    }
}

 

 


Thank you for your help it works if I take out the 'is GridEditFormItem' condition.

 
After that it worked.  Thank you for pointing me in the right direction.

Thanks,
Jeremy

 

 

Tags
Grid
Asked by
Jeremy
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Jeremy
Top achievements
Rank 1
Share this question
or