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

RadGrid programmatic creation

5 Answers 105 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brandon
Top achievements
Rank 1
Brandon asked on 25 Aug 2011, 05:12 PM
Hi,
I am creating several RadGrids programmatically at runtime and am using custom templates for the CommandItemTemplate and for the MasterTableView.EditFormSettings.FormTemplate.  The CommandItemTemplate has a button with command name "InitInsert" and this functions properly and displays my custom FormTemplate.  The FormTemplate has a button with command name "PerformInsert", but the RadGrid ItemCommand function is never fired.

If I call RadGrid.DataBind() immediately upon creation of the RadGrid, the ItemCommand function will fire, but when the "InitInsert" command is fired, the grid which is not the one being edited loses its data and displays blank rows instead.

How can I get the RadGrid to fire its ItemCommand event and maintain the other Grids' data? 
Thank you for your help!
-Brandon

5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 26 Aug 2011, 05:16 AM
Hello Brandon,

Column templates must be added in the Page_Init event handler. Make sure that you are creating the same in Page_Init. Check the following help documentation which explains more about this. Please elaborate your scenario if it doesn't help.
Programmatic Creation.

Thanks,
Princy.
0
Brandon
Top achievements
Rank 1
answered on 26 Aug 2011, 03:26 PM
Hi Princy,

The RadGrids are being created in the Page_Init event handler.  I create a datatable for each grid to use as a DataSource, then create GridTemplateColumns for that grid which all have custom templates.  These columns are working fine. 

I have also added a custom template to insert new items, and a custom template for the CommandItemTemplate.  The CommandItemTemplate consists of only a single button which has a command name of "InitInsert" to fire the proper command to bring up my insert items template.  The problem occurs when I click this button.  The ItemCommand event fires correctly and the grids are all created again due to the function being called from Page_Init, and my custom insert template is shown correctly.  The other grids, however are not bound correctly at this point.  Debugging the program,  I can see that the DataTable I create is correct and is being assigned to the RadGrids.  When the other RadGrids display however they show empty columns with no data in them.  They will display the correct number of columns and rows, but no data is displayed within the cells.
0
Brandon
Top achievements
Rank 1
answered on 26 Aug 2011, 03:49 PM
Ok so I've been debugging it more and it appears that when the InitInsert is fired and the custom templates for the columns are created again, the BindData event in the custom template is only being fired for the grid being edited - but NOT for the other grid.
0
Brandon
Top achievements
Rank 1
answered on 29 Aug 2011, 11:16 PM
Is this behavior over-writable?  I still haven't found a work-around for this problem.  The RadGrid being edited, or inserted into fires correctly and I am able to get the new data to put into the database, but the other grid is still having the issue with displaying data.
0
Brandon
Top achievements
Rank 1
answered on 01 Sep 2011, 04:09 PM
Ok so this was never resolved but I found a work-around to be to use a popup editor rather than in-line editor.
Tags
Grid
Asked by
Brandon
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Brandon
Top achievements
Rank 1
Share this question
or