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

RadGrid dynamic controls and filtering issue

3 Answers 165 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ra
Top achievements
Rank 1
Ra asked on 29 Aug 2008, 01:40 PM
Hi,

I am creating controls dynamically in item created event for RadGrid.
If I set EnableViewState=true for RadGrid, I get Failed to load view state error as the control tree does not match.
But If I Set EnableViewState=false, everything works fine but the filtering does not work correctly for the other columns.
For example, i have a dropdown filter which works fine when i select some item but when i select empty item, it does not filter( does not get all the items back).

I tested by putting EnableViewState=true and commented code which creates controls dynamically..then the filtering works fine..
I am just wondering how i can get both dynamic control creation and filtering to work.

Could you please give your suggestions?

Thanks...

3 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 01 Sep 2008, 12:26 PM
Hi Ra,

I'm not sure how these controls are created at your end however in this example is used very similar approach and there are no problems with filtering.

Sincerely yours,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Ra
Top achievements
Rank 1
answered on 04 Sep 2008, 03:39 PM
Hi,

Thanks for your email. The main issue that I have is I am creating controls based on metadata. For example, if the control type is textbox, dynamically i create a textbox. So based on the control type, in the item_Created event i create the control dynamically and add it to the template column.
 If I set EnableViewState=false for the page, textchanged event handler occurs and filtering works partially( empty item does not retrieve all the items back).
If I set EnableViewState=false for just the grid, event handlers are not occuring.

If I set EnableViewState=true, i get Failed to load view state error as the control tree does not match.

Could you please give me some suggestions or point me to some examples where the controls are being created dynamically.

Thanks a lot....


0
Sebastian
Telerik team
answered on 08 Sep 2008, 01:15 PM
Hi Ra,

How to create grid columns programmatically or dynamically instantiate controls in the existing grid columns you can see from the following online resources:

http://www.telerik.com/help/aspnet/grid/grdprogrammaticcreation.html
http://www.telerik.com/community/code-library/submission/b311D-gtcga.aspx

Furthermore, note that built-in features like grouping/filtering/etc. require the grid viewstate to be enabled. 

Finally, sample code snippets for filtering with MS DropDownLists can be found here. To convert it to the ASP.NET AJAX version of the control follow the steps from the documentation article pointed below:

http://www.telerik.com/help/aspnet-ajax/grdmigrationtoprometheus.html

Best regards,
Stephen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Ra
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Ra
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or