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

Making text boxes wider in automatic edit mode

2 Answers 58 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Andreja Zitnik
Top achievements
Rank 1
Andreja Zitnik asked on 13 Apr 2010, 11:39 AM
Hi,

I am using RadGrid's inbuilt capabilities for editing records and they are quite OK for my needs, but there is one thing that is bugging me. Most of my columns are of type GridBoundColumn and are therefore rendered as textboxes when in edit mode, but they are too narrow for my purposes. How can I make them wider?

Thank you,
Andrea

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 13 Apr 2010, 02:31 PM

Hello Andrea,

You can access the textrbox from code behind and set the Width as per requirement. The code snippet shows an example of how can you achieve the same.

C#:

 
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)   
{   
    if(e.Item is GridDataItem && e.Item.IsInEditMode)   
    {  
        GridEditableItem editItem = (GridEditableItem)e.Item;  
        TextBox textBox = (TextBox) editItem["ContactName"].Controls[0]; // Access the control in EditMode  
        textBox.Width = Unit.Pixel(100); // Set the Width for the textbox  
    }   
}  

-Shinu.

0
Andreja Zitnik
Top achievements
Rank 1
answered on 14 Apr 2010, 10:07 AM
Thank you, Shinu, this was very helpful!
Andrea
Tags
Grid
Asked by
Andreja Zitnik
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Andreja Zitnik
Top achievements
Rank 1
Share this question
or