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

Generate Custom Column Dynamically from Page_Load()

3 Answers 58 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Shane
Top achievements
Rank 1
Shane asked on 03 May 2013, 04:56 PM
Hi,

I'm trying to generate columns dynamically in a RadGrid. I'm currently doing it in the Init() event of the page but when I do it there I get a viewstate error when posting back with filtering turned on. I found a solution that suggests generating the columns in the Page_Load() event, which works for the current issue. However, when I generate the columns from Page_Load(), I get an error message that it can't generate the column with specified type TempoGridDropDownColumn.

I tried with another custom column type and got the same error message. It seems when I generate them from Page_Load() it doesn't support custom column types. If I set EnableColumnsViewState to false I can make the grid work for displaying and adding data. However, without the view state enabled I'm unable to get the selected item into edit mode. When I click Edit Selected the grid structure is lost along with the selected item, so it can't change the item to an editable row.

So I need one of two things. I need to be able to create a custom column type dynamically from Page_Load with EnableColumnsViewState set to true, or I need to be able to edit the selected row with EnableColumnsViewState set to false. Any suggestions?

Shane

3 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 08 May 2013, 10:47 AM
Hello Shane,

Thank you for contacting us.

I would suggest you to review the CodeLibrary below for more information and runnable example on adding custom columns dynamically in RadGrid:
http://www.telerik.com/community/code-library/aspnet-ajax/grid/adding-custom-column-dynamically.aspx


Regards,
Maria Ilieva
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Shane
Top achievements
Rank 1
answered on 08 May 2013, 07:02 PM
Thanks Maria,
But I'm afraid I've already looked at that post. I've also looked at every other post I can find on dynamically constructing the grid structure. I've tried it from Init(), I've tried it from Page_Load(), I've tried it with view state enabled and disabled from both, I've tried it in the Page_Load() on the initial load and in Init() for each subsequent post back. I've tried using a statically declared grid with dynamic columns, I've tried creating the entire grid dynamically. I've tried everything I can find and I've been researching for months.

I was able to get it to create the custom column types, I had to turn the view state off to do that. But that doesn't work either. With ViewState disabled the grid doesn't load properly and shows up empty, along with several other issues. But with ViewState enabled it doesn't create the custom columns.

Like I said, I've tried every combination I can think of and every example I can find. I'm just about ready to give up hope altogether. If you guys can't help me then I'm not sure what to do next.

Shane
0
Maria Ilieva
Telerik team
answered on 13 May 2013, 01:28 PM
Hi Shane,

In case the RadGrid control is correctly created it should load normally no matter if the ViewState is disabled. However it appears that the issue on your end is specific for your custom implementation. Therefore is will be best if you could open a regular support ticket and send us sample runnable application which demonstrates the problem you are facing. Thus we could do our best to debug it locally and provide proper solution for your specific case.

Kind regards,
Maria Ilieva
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
General Discussions
Asked by
Shane
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Shane
Top achievements
Rank 1
Share this question
or