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 8153105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:54:34+00:00 2026-06-06T15:54:34+00:00

I am using a SqlDataSource to bind DetailsView for userprofile, which allows users to

  • 0

I am using a SqlDataSource to bind DetailsView for userprofile, which allows users to view their information and at the same time change their particulars. (select, retrieve and update)

however, this error occured– A field or property with the name ‘Username’ was not found on the selected data source when I click the hyperlink to direct to the “userprofile” page.

Exception Details: System.Web.HttpException: A field or property with the name 'Username' was not found on the selected data source.

Source Error: 

An unhandled exception was generated during the execution of the current web request.   Information regarding the origin and location of the exception can be identified using the   exception stack trace below.

this is the code inside userprofile.aspx file:

  <asp:DetailsView ID="UserProfile" runat="server" 
        AutoGenerateRows="False" DataKeyNames="UserId" 
        DataSourceID="UserProfileDataSource" DefaultMode="Edit" 
        onitemupdated="UserProfile_ItemUpdated">
        <Fields>
           <asp:BoundField DataField="Username" HeaderText="Username" 
                SortExpression="Username" />
            <asp:BoundField DataField="HomeTown" HeaderText="HomeTown" 
                SortExpression="HomeTown" />
            <asp:BoundField DataField="HomepageUrl" HeaderText="HomepageUrl" 
                SortExpression="HomepageUrl" />
            <asp:BoundField DataField="Signature" HeaderText="Signature" 
                SortExpression="Signature" />
            <asp:CommandField ShowEditButton="True" />
        </Fields>
    </asp:DetailsView>

    <asp:SqlDataSource ID="UserProfileDataSource" runat="server" 
        ConnectionString="<%$ ConnectionStrings:SecurityTutorialsConnectionString %>" 

        SelectCommand="SELECT * FROM [UserProfiles] WHERE ([UserId] = @UserId)" 
        onselecting="UserProfileDataSource_Selecting" 
        UpdateCommand="UPDATE UserProfiles SET
        Username = @Username,
        HomeTown = @HomeTown,
        HomepageUrl = @HomepageUrl,
        Signature = @Signature   WHERE UserId = @UserId ">

        <SelectParameters>
        <asp:Parameter Name="UserId" Type="Object" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="HomeTown" />
            <asp:Parameter Name="HomepageUrl" />
            <asp:Parameter Name="Signature" />
            <asp:Parameter Name="UserId" />
        </UpdateParameters>
    </asp:SqlDataSource>

this is the code behind userprofile.aspx.cs :

 protected void UserProfileDataSource_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
    {
        // Get a reference to the currently logged on user
        MembershipUser currentUser = Membership.GetUser();

        // Determine the currently logged on user's UserId value
        Guid currentUserId = (Guid)currentUser.ProviderUserKey;

        // Assign the currently logged on user's UserId to the @UserId parameter
        e.Command.Parameters["@UserId"].Value = currentUserId;
    }

EDIT
I had change the SQL query to:

 SelectCommand= "SELECT [aspnet_Membership].UserId, [HomeTown], [HomepageUrl], [Signature] FROM [UserProfiles] INNER JOIN [aspnet_Membership] ON aspnet_Membership.UserId = UserProfiles.UserId WHERE aspnet_Membership.UserId=@UserId"
    onselecting="UserProfileDataSource_Selecting"
    UpdateCommand="UPDATE UserProfiles SET
    Username = @Username,
    HomeTown = @HomeTown,
    HomepageUrl = @HomepageUrl,
    Signature = @Signature   WHERE UserId = @UserId ">

But the error still appear:
A field or property with the name ‘Username’ was not found on the selected data source

  • 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-06-06T15:54:36+00:00Added an answer on June 6, 2026 at 3:54 pm

    Check the field names in the UserProfiles table. It appears you don’t have a Username field. It is good practice to explicitly state the fields you want to SELECT rather than using the SELECT * FROM .. syntax.

     <asp:BoundField DataField="Username" HeaderText="Username"  
                    SortExpression="Username" /> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using a gridview and SqlDataSource to bind the data table information to the
I had Gridview bind sqldatasource and I had logins which see gridview and I
I bind a SQLDataSource to a GridView using GridView.DataBind() and these queries often take
I am using crystal report (procedure bind) which is not releasing connection when I
I am using SqlDataSource to pull in information from a table such that only
I am retrieving a column from a table using an SqlDataSource in ASP.NET/C#, which
I am using Datagrid and SQLDataSource to bind data from just one table. In
I'm currently using an SqlDataSource in ASP.NET/C# to let users insert, delete and update
I am using a SqlDataSource that returns a table of raw counts. One of
I have asp:GridView displaying client requests using asp:SqlDataSource . I want to limit displayed

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.