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

how to edit the properties of controls inside auto generated edit template

1 Answer 36 Views
Grid
This is a migrated thread and some comments may be shown as answers.
saravanan k
Top achievements
Rank 1
saravanan k asked on 30 Mar 2010, 03:46 PM
hi all,

i need to edit the textmode property of the auotgenerated popup edit mode. is it possible to do it from codebehind. if so which handler to place the logic for the same.

I tried with edittemplate <formtemplate> but it is getting reflected in insert popup too. i want both the templates to be different and with different set of controls.

kindly help me..

Regards,
Saravanan K


1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 31 Mar 2010, 05:56 AM

Hi Saravanan K,

Here is the code snippet that shows how to set the autogenerated TextBox's properties in editmode and insert mode.

C#:

 
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)  
    {  
        if (e.Item is GridEditFormItem && e.Item.IsInEditMode)  
        {  
            GridEditFormItem editItem = (GridEditFormItem)e.Item;  
            TextBox textBox = (TextBox)editItem["CompanyName"].Controls[0];  
            textBox.TextMode = TextBoxMode.MultiLine;  // Set for EditMode  
        }  
        if (e.Item.OwnerTableView.IsItemInserted && e.Item is GridEditFormInsertItem)  
        {  
            GridEditFormInsertItem item = (GridEditFormInsertItem)e.Item;  
            TextBox textBox = (TextBox)item["CompanyName"].Controls[0];  
            textBox.TextMode = TextBoxMode.SingleLine;  // When in insert mode       
        }   
    } 

-Shinu.

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