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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:02:56+00:00 2026-06-08T20:02:56+00:00

Actually, I have this Method wich returns all fields of my table. public ActionResult

  • 0

Actually, I have this Method wich returns all fields of my table.

    public ActionResult Index(string username, string searchString)
    {

        var UserLst = new List<string>();

        var UserQry = from d in db.OrderDetails
                       orderby d.Order.Username
                       select d.Order.Username;
        UserLst.AddRange(UserQry.Distinct());
        ViewBag.username = new SelectList(UserLst);

        var user = from m in db.OrderDetails
                     select m;

        if (!String.IsNullOrEmpty(searchString))
        {
            user = user.Where(s => s.Order.FirstName.Contains(searchString));
        }

        if (string.IsNullOrEmpty(username))
            return View(user);
        else
        {
            return View(user.Where(x => x.Order.Username == username));
        }
    }



    [HttpPost]
    public string Index(FormCollection fc, string searchString)
    {
        return "<h3> From [HttpPost]SearchIndex: " + searchString + "</h3>";
    }

My table looks like that :

Username———Product———-Price———-N°Cart

test————–Object1————-20———–110

test————–Object2————-84———–110

cloud————-Object2————-84———–541

Apple————-Object8————-65———–874

What I want is, when my user is log on and when he’s going to this page, he will see only rows with his username. In other words, I would like my method returns rows with the username of the logged in user.

Excuse me for my english, I wish you’ll understand me.
Thank you for your help, answers, links, I take all, I’m beginner in asp

  • 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-08T20:02:58+00:00Added an answer on June 8, 2026 at 8:02 pm

    If you are using ASP.NET Membership and joining on the Username field from your EF model then just call User.Identity.Name. If so, then you can remove the parameter from the method:

      public ActionResult Index(string searchString)
        {
    
    ...
    ...
    
       return View(user.Where(x => x.Order.Username == User.Identity.Name));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this method: public static Expression<Func<MyEntity, bool>> MyMethod(string someId) { return o =>
Greetings, fellow coders! I have this table that contains categories and subcategories (actually I
I have this extension method for my BusinessObject class: public static class Extensions {
I have a method that deletes files. Actually I have this NSArray *paths =
I have this method: [WebMethod] public OpenAccountResult OpenAccount() { OpenAccountResult test = new OpenAccountResult(/*true*/)//the
Actually I have this list Directory where I am adding the name of the
I have this datatable, actually a list of datatable List<DataTable> lstDataSource , now for
This is a minimal test case of some code that I actually have. It
Actually I have some MVC3 Applications and I want to call this applications from
What does this mean: Next add reference to: MySql.Data actually I have downloaded mysql

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.