Home All Groups Group Topic Archive Search About

Programatically change DataSourceID?

Author
9 Dec 2005 8:57 PM
Brenden Bixler
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.

Author
9 Dec 2005 9:26 PM
Phillip Williams
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.
Author
9 Dec 2005 10:22 PM
Brenden Bixler
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.
Author
12 Dec 2005 7:17 AM
Phillip Williams
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.

AddThis Social Bookmark Button