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

In editmode, change width of all items.

1 Answer 9 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nicklas
Top achievements
Rank 1
Nicklas asked on 25 Jun 2013, 01:02 PM
Hello!

Ive come across a weird problem, Everytime I try to edit my form, the textboxes are in various width. Ive tried sorting this out by iterating thorugh Render.Columns and set the item.Width, with no result.

Eg something like this: 
 if (e.Item is GridEditableItem && e.Item.IsInEditMode)
                {
                    foreach (GridEditFormItem EdItem in rgRadGrid1.Columns)
                    {
                        EdItem.Width = System.Web.UI.WebControls.Unit.Pixel(300);
                    }
}

Ofc this piece of code with yield errors due to the difference of GridEditFormItem and the columns from my rgRadGrid1.

Any idea how to solve this? I ve been stuck for the last hour:) Appreciate any help! (I've tried searching for a solution, but couldn't find anything.)

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 26 Jun 2013, 09:01 AM
Hi Nicklas,

I guess you want to change the width of all columns when in edit-mode.Please try the following code snippet.

C#:
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
    foreach (GridEditFormItem edititem in RadGrid1.MasterTableView.GetItems(GridItemType.EditFormItem))
    {
        foreach (GridColumn col in RadGrid1.MasterTableView.RenderColumns)
        {
            if (col.ColumnType == "GridBoundColumn")
            {
                if (edititem.IsInEditMode)
                {
                    TextBox txtbx = (TextBox)edititem[col.UniqueName].Controls[0];
                    txtbx.Width = Unit.Pixel(500);
                }
            }
        }
    }
}

Thanks,
Princy
Tags
Grid
Asked by
Nicklas
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Share this question
or