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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:48:00+00:00 2026-05-16T07:48:00+00:00

this is my Question extension to this Question .. Here I am able to

  • 0

this is my Question extension to this Question..

Here I am able to add the Dropdown list value to the Grid.. perfectly..

Ex: in my Dropdownlist box I have A B C D items..

When I add any Item I am displaying the grid and I am reloading my page.

My grid have two columns one is added Dropdownlist value.. other is some other text value..

each row in my grid have Edit button..

When I click Edit I am reloading my page to edit this selected dropdownlist value..

when I click Edit I need to show what ever the Dropdownlist value I have in the grid I need to show in the Dropdownlist..

so that user knows he has this dropdown value..

please let me know if any body not undrestood my question..

thanks

My Controler code..

public ActionResult Edit(int? id)
        {
            if (id.HasValue)
            {
               // _viewModel.ObnCategoryTextComponent = _obnRepository.GetObnCategoryById(id.Value);
                 var data = _obnRepository.GetSingle<ObnCategory>(id.Value);
                string selectedValue = data.ObnCategoryName;
                _viewModel.ServiceTypeListAll = new SelectList(_bvRepository.GetAllServiceTypes().OrderBy(n => n.ServiceTypeName), "ServiceTypeName", "ServiceTypeName", selectedValue);
                // _viewModel.Category = data.ObnCategoryName;
            }
            return PartialView("Index",_viewModel);
        }

My View is..

 <%=Html.DropDownList("ServiceTypeListAll",Model.ServiceTypeListAll)%>
  • 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-16T07:48:00+00:00Added an answer on May 16, 2026 at 7:48 am

    You should set the appropriate items Selected property to true:

    public ActionResult Index(int id)
    {
        //string selectedValue = "textOfTheSelectedItem";
        string selectedValue = _bvRepository.GetServiceType(id)  // I only guess, that would be your repository access...
        _viewModel.ServiceTypeListAll = new SelectList(_bvRepository.GetAllServiceTypes().ToList().OrderBy(n => n.ServiceTypeName).ToList(), "ServiceTypeName", "ServiceTypeName", selectedValue);
            return View(_viewModel);
    }
    

    selectedValue must match one of the ServiceTypeNames in the list:

    For the following list, selectedValue must either be “Item 1” or “Item 2”:

    <select>
        <option value="Item 1">Item 1</option>
        <option value="Item 2">Item 2</option>
    </select>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is an extension of the question I asked here I have a relationship
this question is an extension of the question here i tried to extend Dane's
This question is an extension to the one raised here: Using factory_girl in Rails
This question already has an answer here: What are Extension Methods? 5 answers Usage
As an extension to this question here Linking JavaScript Libraries in User Controls I
This is an extension of a question I previously asked here . Long story
This is an extension to the question I asked here: Get text from clipboard
This feels like an extremely n00b question, but here goes... I have a series
this question is an extension of my previous question that you can find here:
This question is extension to the question here . I am using the code

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.