473,387 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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.
Dec 9 '05 #1
3 4474
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.

Dec 9 '05 #2
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.

Dec 9 '05 #3

You are welcome, Brenden.
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"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.

Dec 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Gil | last post by:
Hello, I use VB.NET and have a series of linkbuttons that are inside individual <td>s. Like this: <td background="image.gif"><asp:linkbutton id="myID" runat="server"/></td> I would like...
0
by: Dan Hartshorn | last post by:
VS.NET 2003, C#, Windows Server 2003. I have a datagrid and I want the last column to be either an EditCommandColumn or a template column, depending on a value I have. The value changes for each...
2
by: Edgardo Rossetto | last post by:
Is it possible? Or I must add the control programatically in order to make changes programatically? Edgardo
3
by: misiek | last post by:
Hi all. I have following problem: 1. In my web page I have a GridView control, which does not have a DataSourceId set in designer. 2. When user presses Start button then I create...
8
by: Rak | last post by:
I am looking for a way to programatically change the .net version of the virtual directory that I am creating within a aspx page. As part of creating a new customer in my asp.net 2 application, it...
0
by: mike | last post by:
Hi, When I programatically Bind a DataSource to DetailsView it does not fire "ModeChanged" event. This is first time i am trying to use ASP.NET DetailsView control. I have played with some of the...
1
by: byrd48 | last post by:
Hi I have a really strange problem, I'm working with a project in C# with many dropdownlists and all are databound programmatically using datasource (not datasourceid). Suddenly I am getting the...
0
by: =?Utf-8?B?Sm9ieTY0?= | last post by:
I really do not understand what I am doing wrong. I was trying to get familiar with WebParts and I am getting the following error: The DataSourceID of 'DataList1' must be the ID of a control of...
2
by: =?ISO-8859-1?Q?=22Fernando_A=2E_G=F3mez_F=2E=22?= | last post by:
Hello all. I'm building a WebControl. In it's CreateChildControls, I'm creating a DataSource and a DetailsView controls and set de DV's DataSourceID to the control I just created. Now, I'm...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.