Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6875313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:18:25+00:00 2026-05-27T04:18:25+00:00

I have a SqlDataSource SelectCommand on my .aspx page. <asp:SqlDataSource ID=SqlDataSource1 runat=server ConnectionString=<%$ ConnectionStrings:MyConnectionString

  • 0

I have a SqlDataSource SelectCommand on my .aspx page.

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
     ConnectionString="<%$ ConnectionStrings:MyConnectionString %>"
     SelectCommand="SELECT * FROM [UserResult]"
     OnSelecting="SqlDataSource1_Selecting">
</asp:SqlDataSource>

This statement will grep a list of data from the table UserResult.

However I would only want to list specific results which belongs to the user.

I have attached a column in the UserResult table which is username, and I tried to form an sql statement like this but it seems to search for user User.Identity.nAME :

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
     ConnectionString="<%$ ConnectionStrings:SODConnectionString %>"
     SelectCommand="SELECT * FROM [UserResult] WHERE [username] LIKE 'User.Identity.Name'";"
     OnSelecting="SqlDataSource1_Selecting">
</asp:SqlDataSource>

May I know how can I do it?

Update:

From solution from Curt, I have tried to implement the following:

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
     ConnectionString="<%$ ConnectionStrings:SODConnectionString %>"
     SelectCommand="SELECT * FROM [UserResult] WHERE [username]=@username"
     OnSelecting="SqlDataSource1_Selecting">
     <SelectParameters>
        <asp:Parameter Name="username" Type="String" DefaultValue='<%=User.Identity.Name %>' />
     </SelectParameters>
</asp:SqlDataSource>

However I am still not able to retrieve data according to the username.

I tried to hard code a username into the username parameter and it worked:

Anyone could help?

<asp:Parameter Name="username" Type="String" DefaultValue="james" />
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T04:18:25+00:00Added an answer on May 27, 2026 at 4:18 am

    Your statement is looking for User.Identity.Name because this is set as a string.

    Try using code blocks:

    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
         ConnectionString="<%$ ConnectionStrings:SODConnectionString %>"
         SelectCommand="SELECT * FROM [UserResult] WHERE [username]=@username"
         OnSelecting="SqlDataSource1_Selecting">
         <SelectParameters>
            <asp:Parameter Name="username" Type="String" DefaultValue='<%=User.Identity.Name %>' />
         </SelectParameters>
    </asp:SqlDataSource>
    

    Embedded Code Blocks in ASP.NET Web Pages

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following SQLDataSource : <asp:SqlDataSource ID=topicSource runat=server ConnectionString=<%$ ConnectionStrings SelectCommandType=Text SelectCommand=SELECT *
On an ASP.NET page, I have a SqlDataSource configured with the following SELECT command:
I have a GridView and SqlDataSource for it. SelectCommand is something like SELECT *
in the SqlDataSource, I have specified a SelectCommand that retrieves a date: SelectCommand=SELECT [training_id],
I have an ASP.Net GridView control on an ASPX page hosted on a SharePoint
I have an asp.net dropdown like this <asp:DropDownList width=95% ID=RessourceComposantes runat=server DataSourceID=Composantes DataTextField=Description DataValueField=ComposanteID>
I have asp:GridView displaying client requests using asp:SqlDataSource . I want to limit displayed
I have created a page that loads data from a query string. And creates
I have two dropdowns and a gridview (lstDivisions, lstDistricts, gridIncidents) in an asp.net page
Ok...so I have a page that lists products from a table based on the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.