How to add many textboxes in a grid code-behind

5 posts, 0 answers
  1. Isabelle
    Isabelle avatar
    11 posts
    Member since:
    May 2014

    Posted 25 Feb Link to this post

    Hi,

     

    I can't find a solution to this : I want to create an order form with a grid abd 5 textbox by rows. In these textbox, the user will enter quantity and all the grid will be saved at the save button. So, i need to do this in code-behind. I have this code :

     

     MyGrid.DataSource = ds
     'Colon #0 > DescriptionNaviguateUrl
     mycolumn= New Telerik.Web.UI.GridBoundColumn
    mycolumn.HeaderText = "DescriptionNaviguateUrl"
    mycolumn.DataField = "DescriptionNaviguateUrl"
    mycolumn.Visible = False
    MyGrid.MasterTableView.Columns.Add(mycolumn)

    'Column#1 >Model + COlor
    mycolumn= New Telerik.Web.UI.GridBoundColumn
    mycolumn.HeaderText = "Model #"
    mycolumn.DataField = "Model"
    mycolumn.Visible = False
    MyGrid.MasterTableView.Columns.Add(mycolumn)

     

     

    How can i add a texbox column in the same way?

     

    Thanks!

  2. Eyup
    Admin
    Eyup avatar
    3005 posts

    Posted 26 Feb Link to this post

    Hello Isabelle,

    You can achieve this using Template columns:
    http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/defining-structure/creating-a-radgrid-programmatically#creating-template-columns-programmatically

    Alternatively, you can check the Batch editing provided by RadGrid:
    http://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/batch-editing/defaultcs.aspx

    I hope this will prove helpful.

    Regards,
    Eyup
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Isabelle
    Isabelle avatar
    11 posts
    Member since:
    May 2014

    Posted 26 Feb in reply to Eyup Link to this post

    Thank you very much! Exactly what i want to do!
  5. Isabelle
    Isabelle avatar
    11 posts
    Member since:
    May 2014

    Posted 07 Mar in reply to Eyup Link to this post

    Unfortunately, there is nothing that works for me. I would always add a column to my grid in which there will
    a textbox that I can edit. All codes I find are in asp.net so I want to do everything in vb (code behind)

    So this:


    BoundColumn = New GridBoundColumn ()
             RadGrid1.MasterTableView.Columns.Add (BoundColumn)
             boundColumn.DataField = "## 1 addr"
             boundColumn.HeaderText = "Address"

             BoundColumn = New GridBoundColumn ()
             RadGrid1.MasterTableView.Columns.Add (BoundColumn)
             boundColumn.DataField = "state"
             boundColumn.HeaderText = "Province"

             BoundColumn = New GridBoundColumn ()
             RadGrid1.MasterTableView.Columns.Add (BoundColumn)
             boundColumn.DataField = "country"
             boundColumn.HeaderText = "Country"


    But the next column will be the one to edit ....
  6. Eyup
    Admin
    Eyup avatar
    3005 posts

    Posted 10 Mar Link to this post

    Hi Isabelle,

    You can achieve this requirement by creating programmatic GridTemplateColumn and within its ItemTemplate you can place a textbox control as demonstrated in the sample from the first link in my previous reply. However, since you will be creating the grid during Page_Init, "grid columns should be added to the Columns collection of the MasterTableView after their attributes are set.":
    http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/defining-structure/creating-a-radgrid-programmatically#creating-a-radgrid-on-page_init

    Regards,
    Eyup
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017