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

[Solved] Reload RadGrid in UserControl

1 Answer 114 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 1
Thomas asked on 12 Oct 2009, 01:11 PM
hello,

in my application i have the following scenario:

From a simple ASP.NET page with a few ASP.NET-controls like DropDownList an RadioButton, the user can select a UserControl with an build-in RadGrid. The user first enters some Information and select some values in the ASP.NET page, then he presses a button to load the control based on the selected values (other values loads the same control with different data in the build-in RadGrid).
The Control ist loaded with the LoadControl() from Class Page, whenever the user presses the button.
The Control has a Page_Load with the following code:

if(!IsPostBack) 
  RadGrid.DataSource = my_dataSource; 
  RadGrid.DataBind() 

The RadGrid´s DataSource is updated on every click in the ASP.NET-Page.
In addition, the NeedDataSource Method is implemented:

protected void RadGrid_NeedDataSource(object source, GridNeedDataSourceEventArgs e) 
    RadGrid.DataSource = my_dataSource; 

The following error occurs:

When the user presses the button the first time the control and the RadGrid are loaded correctly. Then, if the user chance the values in the ASP.NET-page and presses the button again the "old" build-in RadGrid is still there!
In debug-mode i figured out that the NeedDataSource is not called, after the control was loaded again.
I try to set the DataSource in the PageLoad on every PostBack, and it works! The new build-in RadGrid was loaded. But then there is an another problem: if the user presses the hide-button, after he has expanded a hierachy nothing happens.

How is it possible to bring these two things (load the RadGrid correctly and hide a hierachy) together?

Thanks for help!




1 Answer, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 15 Oct 2009, 12:44 PM
Hello Thomas,

I already responded in the support ticket you opened with regards to this subject. I am posting my reply in this forum thread for further reference:

Mixing simple with advanced data binding is not supported by our web grid as explained in these online resources:

http://demos.telerik.com/aspnet-ajax/grid/examples/programming/needdatasource/defaultcs.aspx
http://www.telerik.com/help/aspnet-ajax/mostcommonmistakes.html

In case you need to refresh the grid at certain stage of the page lifecycle when using NeedDataSource binding, assign the new data source to it and invoke its Rebind() method (see this topic for details concerning the control lifecycle).

Additionally, please have in mind the Visible/Invisible conventions for the control outlined
here.

Kind regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Thomas
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Share this question
or