EditForms and 100% width multiline Textbox for GridBoundColumn

5 posts, 1 answers
  1. Steele
    Steele avatar
    96 posts
    Member since:
    Mar 2008

    Posted 29 Nov 2010 Link to this post

    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.

  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 30 Nov 2010 Link to this post

    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.
  3. Steele
    Steele avatar
    96 posts
    Member since:
    Mar 2008

    Posted 30 Nov 2010 Link to this post

    Awesome mate!
    Thanks Shinu - the table cell resize was what I was missing.
  4. Orly
    Orly avatar
    2 posts
    Member since:
    Sep 2019

    Posted 30 Sep 2019 in reply to Shinu Link to this post

    What about if i am worked with telerik:GridBoundColumn and i want to have multiline???
  5. Attila Antal
    Admin
    Attila Antal avatar
    521 posts

    Posted 01 Oct 2019 Link to this post

    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.
Back to Top