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

Edit width of a Text box

2 Answers 88 Views
Grid
This is a migrated thread and some comments may be shown as answers.
derek
Top achievements
Rank 2
derek asked on 20 Mar 2009, 03:27 AM
Is it possible to change the width of a text box that is automatically created in the grid edit form?

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 20 Mar 2009, 03:44 AM
Hello Derek,

You can either set the textbox width of a GridBoundColumn when it is in edit mode as shown below:

  protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)  
    {  
        if ((e.Item is GridEditableItem) && (e.Item.IsInEditMode))  
        {  
            GridEditableItem edititem = (GridEditableItem)e.Item;  
            TextBox txtbx = (TextBox)edititem["ColumnUniqueName"].Controls[0];  
            txtbx.Width = Unit.Pixel(100);  
        }   
          
    }  

Another approach is to set column editors for various columns and set their styles declaratively. Refer to the following help document for more information:
Declarative style editors

Thanks
Princy.
0
derek
Top achievements
Rank 2
answered on 20 Mar 2009, 12:32 PM
Awesome, I will give that a shot.  Thank you for your time; however, the link you sent does not work.

I used it and it worked for one column, how do I use this for the other text boxes?  

nevermind, I figured it out!


protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)  
 
{  
 
if ((e.Item is GridEditableItem) && (e.Item.IsInEditMode))  
 
{  
 
GridEditableItem edititem = (GridEditableItem)e.Item;  
 
TextBox txtbx = (TextBox)edititem["Requirement"].Controls[0];  
 
txtbx.Width = Unit.Pixel(800);  
 
}   
 
}  
 
Tags
Grid
Asked by
derek
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
derek
Top achievements
Rank 2
Share this question
or