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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:07:40+00:00 2026-06-13T02:07:40+00:00

I am succesfullly able to save value to database (title value) on insert ,

  • 0

I am succesfullly able to save value to database (title value) on insert , but when i render the same view in edit mode then title field must hold the selected value but in my case no value is selected by title dropdown…dont know why i am getting a dropdown with nothing selected while title field holds the stored value(at backend).

@Html.DropDownListFor(model => model.title, new SelectList(Model.titles, "Value", "Text"),"-Select-") // nothing selected on edit mode

 @Model.title //displaying the stored value which the user selected initially.

values for title

titles = new SelectList(ListItem.getValues().ToList(), "Value", "Text").ToList();

getValue function

 public static List<TextValue> getValues()
      {
    List<TextValue> titles= new List<TextValue>();
    TextValue T= new TextValue();


   T.Value = "Mr";
   T.Text = "Mr";
   titles.Add(T);

    T= new TextValue();
    T.Value = "Mrs";
    T.Text ="Mrs";
       titles.Add(T);

     T= new TextValue();
   T.Value = "Miss";
   T.Text = "Miss";
    titles.Add(T);

    T= new TextValue();
    T.Value ="Other";
   T.Text = "Other";
   titles.Add(T);


    return titles;

   }
  • 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-13T02:07:41+00:00Added an answer on June 13, 2026 at 2:07 am

    You’ve got to use another ctor of SelectList

    From msdn

    SelectList(IEnumerable, String, String, Object) 
    

    Initializes a new instance of the SelectList class by using the
    specified items for the list, the data value field, the data text
    field, and a selected value.

    Then :

    @Html.DropDownListFor(model => model.title, 
                          new SelectList(Model.titles, "Value", "Text", Model.title),
                          "-Select-") 
    

    By the way, it’s generally a good idea to follow basics standards (at least) : your properties should begin by an Upper case char.

    public string Title {get;set;}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am able to save the data to database using the save command. But
In our application the user is able to edit multiple rows at the same
I'm able to successfully set the options for my select list but the selected
Using saveAll() to save multiple records in CakePHP, I am able to save them
I have managed to create a connection to the database and am able to
I have code which is updating a model's property then calling save! . A
I want to save some data into sqlite database and the read it, there
In my apps I have to save tag value of key @v_number from xml
Using Backbone.JS, I am able to successfully create new models and save them to
I was successfully able to grant a user limited permissions to a specific database...

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.