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

Setting Width to Percent for Edit Text Box in GridBoundColumn

1 Answer 153 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 1
Dan asked on 01 Dec 2012, 05:42 AM
I am using two columns in my EditFormSettings, and I want to set the width of the text box on the edit to 90%.  I have tried using  multiple properties on the ItemStyle, like ItemStyle-CssClass="NameOfCssClassThatHas90%Width" and ItemStyle-Width="90%" without any success.  The textbox that shows up only has about 40% width.

Any Suggestions?  As I have about 20 controls in the edit form, using a code-behind isn't my preferred method, and I didn't see how to use a ColumnEditor Class.  Can one columneditor class be attached to multiple GridBoundColumns?

I am trying to create a professional looking application, and without changing that width, it just doesn't look good.

Here is my code for the column, if you are interested.  You will notice this is an "email" type form.

 

 

<telerik:GridBoundColumn DataField="cRegarding" EditFormColumnIndex="0" MaxLength="150"

 

 

 

FilterControlAltText="Filter cRegarding column" HeaderText="Subject"

 

 

 

SortExpression="cRegarding" UniqueName="cRegarding" ></telerik:GridBoundColumn>

 

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 03 Dec 2012, 04:05 AM
Hi,

Try the following code to achieve your scenario.
C#:
protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridEditableItem && e.Item.IsInEditMode)
    {
        GridEditableItem item = (GridEditableItem)e.Item;
        TextBox txt = (TextBox)item["cRegarding"].Controls[0];
        txt.Width = Unit.Percentage(90);
    }
}

Thanks,
Shinu.
Tags
Grid
Asked by
Dan
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or