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

Autogenerated grid with edit mode

1 Answer 11 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alyssa
Top achievements
Rank 1
Alyssa asked on 17 Oct 2013, 11:33 AM
Hi,

I  have an autogenerated grid with edit mode as InPlace. I want to set the width of the textbox in editmode. How to do this as i don't have any unique name since its autogenerated

Thanks,
Alyssa.

1 Answer, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 1
answered on 17 Oct 2013, 11:38 AM
Hi Alyssa,

You can set the width for the TextBox by identifying the column types ,which will be based on the DataType of the columns in DB.

C#:
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
  foreach (GridEditableItem edititem in RadGrid1.MasterTableView.GetItems(GridItemType.EditItem))
    {
        foreach (GridColumn col in RadGrid1.MasterTableView.RenderColumns)
        {
            if (col.ColumnType == "GridBoundColumn")//Checking for BoundColumn
            {
                if (edititem.IsInEditMode)
                {
                    TextBox txtbx = (TextBox)edititem[col.UniqueName].Controls[0];
                    txtbx.Width = Unit.Pixel(60); //Setting width
                }
            }
            if (col.ColumnType == "GridNumericColumn")//Checking for NumericColumn
            {
                if (edititem.IsInEditMode)
                {
                    RadNumericTextBox txtbx = (RadNumericTextBox)edititem[col.UniqueName].Controls[0];
                    txtbx.Width = Unit.Pixel(50); //Setting width
                }
            }
        }
    }
}

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