Programatically change DataSourceID?

G

Guest

Using Visual Studio 2005 / ASP.NET 2.0.

Newbie to ASP 2.0.

I have a GridView and multiple SqlDataSource's on a single page. Each query
is vastly different, but the results share a similar column set. Without
going into details on the project constraints, I was wondering if it's
possible to dynamically change the DataSourceID property of the GridView
control to point to a different SqlDataSource depending on values passed from
another page.

GridView1.DataSourceID = SqlDataSource2 doesn't work.

Thanks in advance.
 
G

Guest

The correct syntax would be:
GridView1.DataSourceID = "SqlDataSource2"; //it needs a string which the ID
GridView1.DataBind(); //do not forget to databind
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,144
Latest member
KetoBaseReviews
Top