RadGrid GridTemplateColumn dynamically added insert mode

2 posts, 0 answers
  1. Jahangeer
    Jahangeer avatar
    19 posts
    Member since:
    Apr 2013

    Posted 20 Nov 2015 Link to this post

    I've RadGrid where I want to add a column dynamically so I've done something like this in page load

                   GridTemplateColumn gtc = new GridTemplateColumn();
                    gtc.DataField = "chqNumber";
                    gtc.HeaderText = "Cheque Number";
                    gtc.UniqueName = "chqNumber";
                    RadGrid1.MasterTableView.Columns.Add(gtc);        

    It work fine, now I want to add textbox in this column as the user click "+add new record" on grid here is my code of itemCreated event 

                                GridEditableItem gdit = (GridEditableItem)e.Item;
                                RadTextBox txtBox = new RadTextBox();
                                txtBox.ID = "someIDWhatEver";

                                gdit["chqNumber"].Controls.Add(txtBox);

    but this textbox gets added to another new column what I mean is this textbox does not added to same chqNumber column you can view my attached image which will illustrate better

    as you can see my dynamic column gets added at the last even after insert and cancel button and dynamic textbox doesn't gets in this column please avoid my english grammatical mistakes :P

     

  2. Eyup
    Admin
    Eyup avatar
    3826 posts

    Posted 25 Nov 2015 Link to this post

    Hello Jahangeer,

    If you want to create a Template column programmatically, please note that the entire grid should be created programmatically during Page_Init:
    http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/defining-structure/creating-a-radgrid-programmatically#creating-template-columns-programmatically

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