473,397 Members | 2,028 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,397 software developers and data experts.

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:SqlDataSource ID="EventsSqlDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:MyConnStr %>" SelectCommand="SELECT
* FROM [MyTable] WHERE [Username] =
'<%Me.User.Identity.Name%>'"></asp:SqlDataSource>

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

Thanks

Regards
Jun 27 '08 #1
2 3123
On Jun 1, 9:42 pm, "John" <i...@nospam.infovis.co.ukwrote:
Hi

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

<asp:SqlDataSource ID="EventsSqlDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:MyConnStr %>" SelectCommand="SELECT
* FROM [MyTable] WHERE [Username] =
'<%Me.User.Identity.Name%>'"></asp:SqlDataSource>

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:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ConnectionStrings:ConnectionS tring %>"
SelectCommand="SELECT * FROM [testtable] where id = '<%
Page.User.Identity.Name %>' "></asp:SqlDataSource>

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.Identity.Name + "%'";

and

data source mark up is

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ConnectionStrings:ConnectionS tring %>" ></
asp:SqlDataSource>
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
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...
2
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...
2
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...
1
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...
2
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...
1
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...
2
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...
1
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...
3
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...
3
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.