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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:50:16+00:00 2026-05-17T02:50:16+00:00

This is my first MVC app and I’m not sure how to use a

  • 0

This is my first MVC app and I’m not sure how to use a parameter to filter the returned data. I’m using MVC2 and Visual Studio 2008.

How do I filter view results based on user input? I want the user to be able to enter an ID number in a textbox and then click a button to get results filtered by the ID they entered.

here is my Controller

    public class HelloWorldController : Controller
    {
        UAStagingEntities db = new UAStagingEntities();

        public ActionResult Index()
        {
            var depot = from m in db.CSLA_DEPOT
                        where m.DEPOT_ID==10057
                        select m;

            return View(depot.ToList());

        }
    }

how do I change this to accept a paramter instead of a hard coded ID?

  • 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-17T02:50:17+00:00Added an answer on May 17, 2026 at 2:50 am

    Initially try getting it working from the address bar in your browser.

    Change the code to receive an Id parameter:

    public ActionResult Index(int Id)
    {
        var depot = from m in db.CSLA_DEPOT
                    where m.DEPOT_ID==id
                    select m;
    
        return View(depot.ToList());
    
    }
    

    Then you should be able to call …/controller/action/id

    Next add an actionLink to your webpage to call this action

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

Sidebar

Related Questions

This is my first project using StructureMap, it is an MVC web app and
I am writing a web app using MVC and the first page will be
I'm creating an asp.net MVC app, first time I've done this. I have a
Hey everyone.. This is my first time writing an ASP.NET MVC web app, and
I want to build an MVC app using Spring (first timer here). As such
I'm using Ninject with an MVC app, also using EF4.1 Code First. I'm getting
I'm building my first ASP.NET MVC 3 app and using jqGrid. One of my
I am working on a mvc3.0 app using EF code first and mvc scaffolding.
This is my first experience using the Zend Framework. I am attempting to follow
this is my first question to stackoverflow so here it goes... I use cruise

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.