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

Rad Grid help on insert a new record and edit

1 Answer 35 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Fernando Fonseca
Top achievements
Rank 1
Fernando Fonseca asked on 01 Sep 2010, 04:55 PM
Hello everyone!! ok here is my case, i have my RadGrid, and if i want to add a new record, it shows my 3 textbox, so i can enter my data and save it. But when i want to edit data it shows my 3 textbox, how do i select wich textbox leave enabled or disabled, so the user cannot modify some of them.
Thank you very much for your help :)

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 02 Sep 2010, 06:52 AM
Hello Fernando,

           Accessing the textbox control rendered in editform and setting the Enabled property in ItemDataBound event, will help you to achieve the functionality. Here is the code sample.

MarkUp:

<telerik:GridBoundColumn DataField="LastName" HeaderText="LastName"  UniqueName="LastName">
</telerik:GridBoundColumn>

Code Behind

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
   {
  if (e.Item is GridEditableItem && e.Item.IsInEditMode)
       {
           GridEditableItem editItem = (GridEditableItem)e.Item;
           TextBox txt = (TextBox)editItem["LastName"].Controls[0];// You can also clear the controls in the cell using Controls.Clear() method
           txt.Enabled = false;
        }
    }


Regards,
Shinu.
Tags
Grid
Asked by
Fernando Fonseca
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or