This is a migrated thread and some comments may be shown as answers.
Issue Dynamically changing Datasource for Grid
2 Answers 52 Views
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 24 Mar 2009, 03:45 PM
I have the latest development build (2009.1.311.35).  I have a grid control that I dynamically change the datasource to.  If I change the datasource to a method that returns more results then everything seems to work great, but then when I change to a datasource with less results then number of items and pages that are available to select from are still reflecting the old datasource.

* Note with one of the datasources I have implemented custom paging. 

Rick

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 25 Mar 2009, 06:11 AM
Hi Richard,

I am not sure what exactly is the issue. One suggestion will be to clear the DataSource of the Grid first and then assign the new Data.

CS:

//Clear the DataSource of the Grid
 
RadGrid1.DataSource = new string[] { }; 
//Assign the new DataSource here 
//RadGrid1.DataSource=ds;  

Thanks
Shinu
0
Richard
Top achievements
Rank 1
answered on 25 Mar 2009, 02:38 PM
I am using ObjectDataSource's, and setting the DataSourceID dynamically not the DataSource.  One of the data source objects is using the paging feature IE (someBLL class) this allows a large number of rows in the result set without having to retreive them all each time the Grid is rebound (it is only retrieves the rows that I need to display). 

 


Look at this picture!  When switching back and forth between DataSourceID's and you have a datasource that implements the advanced paging feature, then it may still show the old number of the items from the previous datasource. (This does NOT happen when I am using DataSource objects that do not use the paging feature....)

--> http://al.dynavoxtech.com/misc_pics/please_look.bmp

 

  <asp:ObjectDataSource ID="AdminFilesOrderByLastUpdated" runat="server"   
              DeleteMethod="Delete" InsertMethod="Insert"   
              OldValuesParameterFormatString="original_{0}"   
              SelectMethod="GetAllFileForAdminByLastUpdated"   
              TypeName="AdaptedLearningBLL"   
              UpdateMethod="Update" EnablePaging="True" SelectCountMethod="TotalNumberOfFiles">  
          </asp:ObjectDataSource> 

 

Tags
Grid
Asked by
Richard
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Richard
Top achievements
Rank 1
Share this question
or