473,471 Members | 2,053 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

sqldatasource control return from Method won't bind

Hi,

I have 2 scenarios. (1) works, but (2) doesn't
------------------------------------------------------------
1)
I have sqldatasource control using OracleClient. I'm setting the
attributes in a codebehind module. This works fine. The DataView that
it is bound to it comes up with data.

2)
I tried creating a helper class that would return a sqldatasource. I
create the sqldatasource in the class and set it to the same
attributes that I did in the first test above. The code behind sets the
sqldatasource on the page to the function which is returning a
sqldatasource. I can see the newly set attributes in the debugger. The
problem is that it is not binding to the dataview.

Inside form1_Load - This works
-----------------------------
dataSource.ProviderName = "System.Data.OracleClient"
dataSource.ConnectionString = "Data Source=blah;Persist Security
Info=True;User ID=lah;Password=blah;Unicode=True"
dataSource.SelectCommand = "select * from theTable"
dataSource.SelectCommandType = SqlDataSourceCommandType.Text

The above works fine.

If I do the following, then it will not bind
--------------------------------------------------------
Me.dataSource = da.MyDataSource

Has anyone encountered this before?

Thanks in advance, Gabe

Nov 7 '06 #1
1 1538
Sorry, Nevermind.

I just realized that in effect, I was reassigning the reference from
the datasource that was on the page to the anonymous datasource
returned from the function, which falls out of scope at the end of the
method.

If I passed it in byRef, then it works.

Thanks Anyway ---

gabe wrote:
Hi,

I have 2 scenarios. (1) works, but (2) doesn't
------------------------------------------------------------
1)
I have sqldatasource control using OracleClient. I'm setting the
attributes in a codebehind module. This works fine. The DataView that
it is bound to it comes up with data.

2)
I tried creating a helper class that would return a sqldatasource. I
create the sqldatasource in the class and set it to the same
attributes that I did in the first test above. The code behind sets the
sqldatasource on the page to the function which is returning a
sqldatasource. I can see the newly set attributes in the debugger. The
problem is that it is not binding to the dataview.

Inside form1_Load - This works
-----------------------------
dataSource.ProviderName = "System.Data.OracleClient"
dataSource.ConnectionString = "Data Source=blah;Persist Security
Info=True;User ID=lah;Password=blah;Unicode=True"
dataSource.SelectCommand = "select * from theTable"
dataSource.SelectCommandType = SqlDataSourceCommandType.Text

The above works fine.

If I do the following, then it will not bind
--------------------------------------------------------
Me.dataSource = da.MyDataSource

Has anyone encountered this before?

Thanks in advance, Gabe
Nov 7 '06 #2

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

Similar topics

15
by: Swetha | last post by:
Hello I have a DropDownList that I am populating using the following SqlDataSource: <asp:DropDownList ID="parentIDDropDownList" runat="server" DataSourceID="SqlDataSource3"...
2
by: Ned Balzer | last post by:
I'm trying to create a formview bound to a sqldatasource, and use a stored procedure to insert data from the formview into several tables. I have some simplified code below, the real code is much...
3
by: Asaf | last post by:
Hi, I have SqlDataSource control that makes a "select count" to show how many rows there are in a Table and it is working fine on first page load. The problem is that when I am inserting a new...
6
by: djc | last post by:
I had previously (in asp.net 1.1 and asp.net web matrix) just done this to populate a listbox with data from a database: ------------ this was from the page load event ---------------- 'fill...
6
by: Ken Fine | last post by:
I'm using SQLDataSource, which generates some kind of dataset, and then I attach that datasource to various data display controls such as DataList and repeater which loop through to the end of the...
2
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
Hi, I want to create a mailto link from data coming from an SQLDataSource. How do I have to change the following code to get it working? The mailto works, outlook starts with a new message, but...
0
by: =?Utf-8?B?X3ByZWZpeA==?= | last post by:
Hello All, I have written a page with a sqlserverdatasource control and a formview web control. I want to use stored procedures to perform CRUD operations. Formview textboxes bind to table...
2
by: makennedy | last post by:
Hi Experts, Please help, I am a newbie to ASP.NET 2.0 may be I am doing something wrong or there may be a bug somewhere. Basically I have a TreeView Control which I have created...
3
by: Roger Jordan | last post by:
Hello, I'm using a SQLDataSource with name SqlDataSource1, the DeleteCommand has a parameter, with isdefined in SqlDataSource.DeleteParameter: DELETE FROM WHERE =@ID The parameter is not...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.