473,322 Members | 1,405 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,322 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 3117
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
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.