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

[Solved] Edit/new record form

3 Answers 66 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Carlos
Top achievements
Rank 1
Carlos asked on 02 May 2013, 03:58 PM
Hi all is there a possibility in a automatic created Edit/New Record form to disable some fields??

Best regards

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 03 May 2013, 03:58 AM
Hi,

Please take a look into the following code snippet I tried to disable a the TextBox in edit and insert mode.

C#:
protected void myRadGrid_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    if (e.Item is GridEditableItem && e.Item.IsInEditMode)
    {
 
            GridEditableItem EditItem = (GridEditableItem)e.Item;
            TextBox txt = (TextBox)EditItem .FindControl("TextBox1"); // disabling a TextBox in TemplateColumn
            txt.Enabled = false;
 
            TextBox txtbound = (TextBox)EditItem ["UniqueName"].Controls[0]; // disabling a BoundColumn
            txtbound.Enabled = false;   
    }
}

Thanks,
Princy.
0
Carlos
Top achievements
Rank 1
answered on 06 May 2013, 09:25 AM
HIo thanks for the aswer but the problem is that i dont have a templatecolumn the grid it beeing made automatic.

Best Regards.
0
Shinu
Top achievements
Rank 2
answered on 06 May 2013, 09:41 AM
Hi,

Try the following.
c#
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
  if (e.Item is GridEditableItem && e.Item.IsInEditMode)
  {
      GridEditableItem item = (GridEditableItem)e.Item;
      TextBox txt = (TextBox)item["DataFieldName"].Controls[0];
   txt.Enabled = false;
    }
}

Thanks,
Shinu
Tags
Grid
Asked by
Carlos
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Carlos
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or