sqldatasource control return from Method won't bind

G

gabe

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
 
G

gabe

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 ---
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top