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

RadGrid GridTemplateColumn dynamically added insert mode

1 Answer 267 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jahangeer
Top achievements
Rank 1
Jahangeer asked on 20 Nov 2015, 01:49 PM

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

 

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 25 Nov 2015, 12:05 PM
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
Tags
Grid
Asked by
Jahangeer
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or