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

EditForms and 100% width multiline Textbox for GridBoundColumn

4 Answers 349 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Steele
Top achievements
Rank 1
Steele asked on 30 Nov 2010, 04:15 AM
Hi All,
I have a Grid with a BoundColumn that I would like to have the input as a multiline textbox, taking up the width of the grid (that is to the right of the edit form headings).
See the attached picture to see what I mean.
It seems that the Edit Form is not the width of the Grid, but much smaller (it's bounds are where the Textbox ends currently).
I am trying to set the 100% width in the ItemDataBound event of the RadGrid by :
TextBox tb = null;
GridDataItem gdi = e.Item as GridDataItem;
tb = (TextBox)gdi["Notes"].Controls[0];
Is there another way to get this field to become wider?  Setting it to a pixel value works, but is not ideal.
Thanks,
Steele.

4 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 30 Nov 2010, 07:55 AM
Hello,


I tried setting the width of the Table and TableCell which contains the TextBox control in edit-form and got worked for me. Give a try with the following code and see whether it work for you.

Code:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
    {
        GridEditFormItem editItem = e.Item as GridEditFormItem;
        Table editTable = (editItem.EditFormCell as GridEditFormItem.EditFormTableCell).Controls[0].Controls[0] as Table;
        editTable.Width = Unit.Percentage(100);
        TextBox textBox = (TextBox)editItem["Notes"].Controls[0];
        textBox.TextMode = TextBoxMode.MultiLine;
        (textBox.Parent as TableCell).Width = Unit.Percentage(100);
        textBox.Width = Unit.Percentage(100);
    }
}
[I guess you are using AutoGenerated editform]


Happy coding .. :)

-Shinu.
0
Steele
Top achievements
Rank 1
answered on 01 Dec 2010, 12:17 AM
Awesome mate!
Thanks Shinu - the table cell resize was what I was missing.
0
Orly
Top achievements
Rank 1
answered on 30 Sep 2019, 01:15 PM
What about if i am worked with telerik:GridBoundColumn and i want to have multiline???
0
Attila Antal
Telerik team
answered on 01 Oct 2019, 07:33 PM

Hi Orly,

Practically you can access the controls of any Column, Template or Bound Columns, event automatically generated ones. Check out the article describing more about that: Accessing Cells and Rows

There you will get a better idea how to access cells, controls if different types of columns. It may not cover all possible scenarios, but will give you a great idea from which you can improvise.

Kind regards,
Attila Antal
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
Steele
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Steele
Top achievements
Rank 1
Orly
Top achievements
Rank 1
Attila Antal
Telerik team
Share this question
or