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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:34:59+00:00 2026-05-22T03:34:59+00:00

<select id=DropList> @foreach (var item in Model.CategoryList) { <option value=@item.Id> @item.Name </option> } </select>

  • 0
    <select id="DropList">
          @foreach (var item in Model.CategoryList)
          {

            <option value="@item.Id">
                @item.Name
            </option>
          }
    </select>

This list holds categories of pictures. There is a database holds pictures information and categoy information. When i choose a category from the list, i want to see all the pictures that belong to the category.
This is my list. I want the controller to give me pictures when i change the value in the list.
I am using jQuery to take the id from the selected list element but how can i get the pictures.

This code works:

        @foreach (var item in Model.CategoryList)
        {
            <a id="aa" href="@Url.Action("Index", "Home", new { id = @item.Id })">@item.Name</a>

            <br />
        }
        <br />
        <a href="@Url.Content("http://localhost:55197/Home/CategoryEkle")">Yeni Kategori Ekle</a>

I want to the same for the drop down list.

  • 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-22T03:35:00+00:00Added an answer on May 22, 2026 at 3:35 am

    @Rory’s comment on your post is a good one. But rather than putting it in the ViewModel (since controllers don’t care about the way that views display things), I’d do this in the view:

    @{
        var cats = new List<SelectListItem>();
        foreach (var item in Model.CategoryList)
            cats.Add(new SelectListItem() { Text = item, Value = item.Id });
    }
    
    @Html.DropDownList("DropList", cats)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<select name=DropList id=serverDropList> <option selected=selected value=2>server1:3000</option> <option value=5>server3:3000</option> </select> i know in prototype i
I have two droplist in html built using tag. <select name=List1 id=List1 onclick=GetVal()> <option
I have this function for adding options to a Select list: function addOption(selectbox, value,
select picks.`fbid`, picks.`time`, categories.`name` as cname, options.`name` as oname, users.`name` from picks left join
I have a problem with a generated droplist, it shows up like this: <select
select email from mailing list This is the query i want to use if
SELECT `name` , COUNT(*) AS `count` FROM `t1`, `t2` WHERE `t2`.`id` = `t1`.`id` GROUP
SELECT pe.prodtree_element_id prodID, pe.prodtree_element_name_s, li.line_name, av2.value FROM prodtree_element pe LEFT JOIN prodtree_link pl ON
SELECT * FROM (SELECT ROW_NUMBER() OVER (ORDER BY hrl.Frn) as Row, hrl.unq, hrl.LcnsId, hc.Business,hc.Name,hc.Phone,
select log_reuse_wait_desc from sys.databases where name = 'mydb' 1. LOG_BACKUP All update and insert

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.