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

Setting the length of a textbox in edit mode

1 Answer 93 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brendan Vogt
Top achievements
Rank 1
Brendan Vogt asked on 10 Jul 2008, 08:43 AM
Hi,

If a row in a grid goes into edit mode, how do I set the length of the textbox?  Currently it just put in a textbox with a default length.

Here is my code:

<radG:GridBoundColumn
   UniqueName="CurrentAccountNumber"
   DataField="CurrentAccountNumber"
   HeaderText="Current Account Number" />

Thanks
Brendan

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 10 Jul 2008, 09:23 AM
Hello Brendan,

You can set the length of the TextBox in edit mode as shown in the code snippet below.

CS:
 protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if ((e.Item is GridEditFormItem) && (e.Item.IsInEditMode)) 
            { 
               GridEditFormItem edititem = (GridEditFormItem)e.Item; 
               TextBox txtbox = (TextBox)edititem["CurrentAccountNumber"].Controls[0]; 
               txtbox.Width = Unit.Pixel(100); 
            } 
    } 

Thanks
Princy.
Tags
Grid
Asked by
Brendan Vogt
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or