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

[Solved] EditMode TextBox Control width

1 Answer 159 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 17 May 2008, 08:16 AM
Hi,

i have a RadGrid, which on editmode displays a textbox by default.
How can i set the width of the textbox based on the number of characters in it?

Thanks
Daniel

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 19 May 2008, 07:01 AM
Hi Daniel,

Try setting the width of the textbox in edit mode as shown below.

CS:
 protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
     { 
         if ((e.Item is GridEditableItem) && (e.Item.IsInEditMode)) 
         { 
             GridEditableItem Edititem = (GridEditableItem)e.Item; 
             TextBox txtbx = (TextBox)Edititem["ProductName"].Controls[0]; 
            
             if (txtbx.Text.Length >5 ) 
             { 
                 txtbx.Width = Unit.Pixel(200); 
             } 
 
         } 
   } 


Hope this helps..
Shinu.
Tags
Grid
Asked by
Daniel
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or