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

  • Home
  • SEARCH
  • 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 6833473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:58:58+00:00 2026-05-26T22:58:58+00:00

I am retrieving some configuration from a service and passing this data to the

  • 0

I am retrieving some configuration from a service and passing this data to the edit view. The user can make changes to the text and check box fields and these values are returned fine.

I have a drop down list populated with the values from an enum for the database type. These values are passed to the view and are displayed correctly but when the user changes the selection, the first value in the list is applies to the data model.

Below is some code from the controller and view.

The Controller:

[HttpPost]
public ActionResult Edit( SettingsModel config)
{
    try
    {
        List<string> configErrors = null;

        if (ModelState.IsValid)
        {
            // Set up a channel factory to use the webHTTPBinding
            using (WebChannelFactory<IChangeService> serviceChannel = new WebChannelFactory<IChangeService>(new Uri(baseServiceUrl)))
            {
                IChangeService channel = serviceChannel.CreateChannel();
                configErrors = channel.SetSysConfig(config);

                // Check for any errors returned by the service
                if (configErrors != null || configErrors.Count > 0)
                {
                    // Display the errors at the top of the page
                    ViewData["ConfigErrors"] = configErrors;

                    // TODO: Force the redisplay of the page

                }
            }
        }

        ViewData["DBTypes"] = new SelectList(Enum.GetValues(typeof(DatabaseType)), config.DBType);

        return RedirectToAction("Index", config);
    }
    catch
    {
        return View();
    }
}

The Edit view:

<tr>
    <td>
        <h4>Database Type</h4>
    </td>
    <td>
        @Html.DropDownList("Database Type", ViewData["DBTypes"] as SelectList )
    </td>
    <td>
        @Html.ValidationMessageFor(model => model.DBType)
    </td>
</tr>
  • 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-26T22:58:59+00:00Added an answer on May 26, 2026 at 10:58 pm

    Try to change the view like this

    @Html.DropDownListFor(model => model.DBType, ViewData["DBTypes"] as SelectList, "select a value")
    

    This should persist the selection to the property DBType of your model

    Or change your row like this to obtain the same result

    @Html.DropDownList("DBType", ViewData["DBTypes"] as SelectList )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anybody help me with retrieving some elements from the following example text: sdfaasdflj
I am retrieving some data from the server which looks something like this: 1:some
For some reason I'm having a problem retrieving data from my database. It leaves
i posted some data using tinymce (in a symfony project).while retrieving back how can
When retrieving a lookup code value from a table, some folks do this... Dim
I'm retrieving some data from Twitter using the code below Dim FilterData = follow=13,15
In my case I am retrieving some data from the backend. In that one
I am using Django for development, retrieving some text containing a newline character from
In my java code,I am retrieving some multibyte data from database and making some
how to cache data source contents? suppose I'm retrieving some records from my sql

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.