473,543 Members | 2,405 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Passing values to sql datasource

Hi

I am trying to pass the asp.net membership username to the sqldatasource of
a gridview as below;

<asp:SqlDataSou rce ID="EventsSqlDa taSource" runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:MyConnStr %>" SelectCommand=" SELECT
* FROM [MyTable] WHERE [Username] =
'<%Me.User.Iden tity.Name%>'"></asp:SqlDataSour ce>

It is not working. How can I do it correctly?

Thanks

Regards
Jun 27 '08 #1
2 3131
On Jun 1, 9:42 pm, "John" <i...@nospam.in fovis.co.ukwrot e:
Hi

I am trying to pass the asp.net membership username to the sqldatasource of
a gridview as below;

<asp:SqlDataSou rce ID="EventsSqlDa taSource" runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:MyConnStr %>" SelectCommand=" SELECT
* FROM [MyTable] WHERE [Username] =
'<%Me.User.Iden tity.Name%>'"></asp:SqlDataSour ce>

It is not working. How can I do it correctly?

Thanks

Regards
Hi i have tried your same code and worked okay make be you are meesing
some thing....

here is the code i tried..

<asp:SqlDataSou rce ID="SqlDataSour ce1" runat="server"
ConnectionStrin g="<%$Connectio nStrings:Connec tionString %>"
SelectCommand=" SELECT * FROM [testtable] where id = '<%
Page.User.Ident ity.Name %>' "></asp:SqlDataSour ce>

Best of luck

Munna
www.munna.shatkotha.com
www.munna.shatkotha.com/blog
www.shatkotha.com
Jun 27 '08 #2
Hi its me again...

I found another way to make things work i have tested it and works
pretty fine..
in markup i actually didn't put any select command.

instead i left the select command blank

i assigned the select command in code behind file in page load
event ...

SqlDataSource1. SelectCommand = "SELECT * FROM [testtable] where id
like '%" + Page.User.Ident ity.Name + "%'";

and

data source mark up is

<asp:SqlDataSou rce ID="SqlDataSour ce1" runat="server"
ConnectionStrin g="<%$Connectio nStrings:Connec tionString %>" ></
asp:SqlDataSour ce>
Best of luck

Munna
www.munna.shatkotha.com
www.munna.shatkotha.com/blog
www.shatkotha.com
Jun 27 '08 #3

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

Similar topics

4
3135
by: rick | last post by:
Does anyone having a working example of passing values between web forms pages? I tried the example in the ms- help but I can't get by the following: To read property values from the source page in the call page. 1. Create a global instance varible that is typed to the class of the source page. the sample provided
2
380
by: Jim Heavey | last post by:
I know that I can create session variables and pass those values from one screen to another, but is there not a way to makes variables from one scree n available to another screen other then session variables? Is there not a way to create properties in the one screen and then pass some sort of reference to the screen you are calling? Can...
2
1996
by: VS_NET_DEV | last post by:
Hi All, There two ways of passing values between pages - 1) Context.Items.Add 2) Context.Handler (cast the page1 class etc) I know for sure #2 does not store the values between requests. How about #1. Does it store values between requests? i.e. The Context.Items. collection A)Is it like the Session variables?
1
2692
by: olduncleamos | last post by:
Hello all. With a background in ASP, I am finding the work required for passing values between pages mystifying. For various obvious reasons, I have eliminated using cookies and session to store state data. The only ASP.NET options left is to use the Server.Transfer to transfer to page 2 from page 1, and then use the context to get whatever...
2
1472
by: Ganesh | last post by:
Hi there, I'm new to .net just started with 2005 and asp.net 2.0, I'm passing control values to other page to retrieve the data from data set based on the passing values. It works fine. But when i click any field for sorting it looses the values of previous form i guess so. How can i do this, what sort of techniquest people are doing for...
1
2329
by: Steve | last post by:
After a few hours of trial and error I have reached the following conclusions, can you please tell me if I am right: I have 2 aspx pages both with the same master page and I wish to pass values from one to the other. 1. The postbackurl method doesn't seem to work with master pages. If I take away the master pages it works. 2. The...
2
2275
by: johnj | last post by:
I am converting an application I wrote in VB.NET to C#. I am not a C# guy, at all. I am having a problem passing values to a property in C#. I understand that it is probably not the best way of achieving my result, but it works in VB.NET, flawlessly. Basically, I am storing a bunch of settings in a hashtable. Then, setting/getting my values...
1
1519
by: swapna | last post by:
hi, in my project,i have problem i.e dynamically should pass values to checkboxes.i am using Jsp technology/html.in html i created checkbox but passing values to that checkbox dynamically in javascript should come,but it is not working.pls try to help me to solve my problem.
3
6434
by: vidhyapriya | last post by:
Hi all I am developing windows application using vb.net.I want to pass values to open form.I am opening only one form when user click the buttons several times.Useing delegate i am passing values for first time.Next time when user click the button i want to pass value to open form.How to pass value to open form.Can anyone help me plz.Thanx...
3
2468
by: Archanak | last post by:
Hi, Any limits exists while passing values of checkbox to another program? Here is the code: <script type="text/javascript"> function valuate() {
0
7401
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7732
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7681
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5881
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5260
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3391
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1810
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 we have to send another system
1
958
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
628
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.