473,480 Members | 4,939 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

DataSource Parameter with dynamic value

ASP.NET 2.0

I have a SqlDataSource that i'd like to pass the UserID of the user defined
by the Membership provider.

So, I thought I'd do something like this:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:acpConnectionString %>"
SelectCommand="SELECT [balance] FROM [accounts] WHERE ([UserID] = @UserID)" EnableViewState="False">
<SelectParameters>
<asp:Parameter Name="UserID" Type="Object" DefaultValue="<%= Membership.GetUser(false).ProviderUserKey %>"/>
</SelectParameters>
</asp:SqlDataSource>

ProviderUserKey is a GUID, and my SQL Data type is a uniqueidentifer. This
doesn't generate any kind of exception, but it just returns no data.

If, however, I use a SessionParameter, and copy the ProviderUserKey into a
Session variable, it works and returns the record as expected.

It seems like the ASP code in the Parameter tag isn't executing, any ideas
how to fix this? I'd rather not use the session variable if I don't have
to.
Nov 19 '05 #1
0 1095

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

Similar topics

0
5390
by: no-spam | last post by:
Hello group, I have some questions concerning configuring and using a JNDI DataSource with PostgreSQL and Apache Tomcat. Currently, I belive I have successfully configured a "basic" DataSource....
4
16947
by: Todd Perkins | last post by:
Hello all, surprisingly enough, this is my first newsgroup post, I usually rely on google. So I hope I have enough info contained. Thank you in advance for any help! Problem: I am getting...
5
3061
by: Ron | last post by:
I have a bunch of Crystal Reports (v9) published as WebServices and use a ReportViewer to display the reports on the ASPNET page. Everytime we move the reports from dev to production we have to...
2
1369
by: Not Me | last post by:
Hi, I'm a little confused with working with parameters for a datasource - specifically when it comes to naming them. For example <asp:parameter Name="surname" type="String" /> this...
1
3736
by: sck10 | last post by:
Hello, I have a GridView that has AutoGenerateSelectButton="true". When the "Select" link is clicked, it opens a FormView with the appropriate data. Below is the following SelectParameter that...
1
1143
by: sck10 | last post by:
Hello, I have two datasources. The first one pulls data from a Stored Procedure. The second one from an SQL String. They both get there parameter value from a GridView...
6
1500
by: WebBuilder451 | last post by:
I have a drop down list of saved searches for a user and i'm trying to use the datasource control to populate the ddl. The select value in the storedproc is the user.Identity.name. How can i use...
0
1132
by: namewitheldbyrequest | last post by:
I have a FrameView control on a form. In the FrameView is a DropDownList that has as its datasource an ObjectDataSource object. The ObjectDataSource is not in the FrameView because I get an error...
0
7041
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
7080
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
6736
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
6908
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
4478
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
2994
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2980
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1299
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 ...
0
178
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.