|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Programatically change DataSourceID?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. The correct syntax would be:
GridView1.DataSourceID = "SqlDataSource2"; //it needs a string which the ID GridView1.DataBind(); //do not forget to databind Show quote "Brenden Bixler" wrote: > 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. Thanks Phillip, it worked.
Much appreciated. -Brenden Show quote "Phillip Williams" wrote: > The correct syntax would be: > GridView1.DataSourceID = "SqlDataSource2"; //it needs a string which the ID > GridView1.DataBind(); //do not forget to databind > -- > HTH, > Phillip Williams > http://www.societopia.net > http://www.webswapp.com > > > "Brenden Bixler" wrote: > > > 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. You are welcome, Brenden.
Show quote "Brenden Bixler" wrote: > Thanks Phillip, it worked. > > Much appreciated. > > -Brenden > > "Phillip Williams" wrote: > > > The correct syntax would be: > > GridView1.DataSourceID = "SqlDataSource2"; //it needs a string which the ID > > GridView1.DataBind(); //do not forget to databind > > -- > > HTH, > > Phillip Williams > > http://www.societopia.net > > http://www.webswapp.com > > > > > > "Brenden Bixler" wrote: > > > > > 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. |
|||||||||||||||||||||||