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

How to change grid source in page load?

1 Answer 70 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Raul
Top achievements
Rank 1
Raul asked on 28 Dec 2008, 05:04 PM
Hi All,

I have a grid in a page, loading data from sqldatasource, but I want to change this grid datasource in page load if I received a specific parameter, so how I can change grid source in page_load event in special case?

Please advise.

Regards

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 29 Dec 2008, 05:54 AM
Hello Raul,

You can try out the following code to change the datasource of the RadGrid in the PageLoad event.
cs:
protected void Page_Load(object sender, EventArgs e) 
    { 
       if (condition == "satisfied") 
        { 
         //to clear datasource for the grid 
          RadGrid1.DataSource = String.Empty; 
         //to set another datasource 
          RadGrid1.DataSourceID = "SqlDataSource2"
        }      
    } 

Thanks
Princy.
Tags
Grid
Asked by
Raul
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or