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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:59:30+00:00 2026-05-11T18:59:30+00:00

Using the following form in a view <% using (Ajax.BeginForm(PatientSearch, new {}, new AjaxOptions()

  • 0

Using the following form in a view

<% using (Ajax.BeginForm("PatientSearch", new {}, new AjaxOptions()
           {
               HttpMethod = "POST",
               UpdateTargetId = "searchResults",
               OnBegin = "BeginRequest",
               OnSuccess = "SuccessRequest",
               OnFailure = "FailRequest"
           }))
           { %>
    <%=Html.DropDownList("patientType",(SelectList)ViewData["PatientTypeList"]) %>
    <%=Html.DropDownList("edCenterID",(SelectList)ViewData["EdCenterList"]) %><br />
    <input type="submit">
<%} %>

Results in the following HTML

<select id="patientType" name="patientType">
  <option selected="selected">Referral</option>
  <option>Patient</option>
</select>
<select id="edCenterID" name="edCenterID">
  <option value="2">Barren River District Health Department</option>
  <option value="3">Madison County Health Department</option>
</select>

and I attempt to catch the values with the code in the my controller

 public ActionResult PatientSearch(string patientType, int edCenterID)        {   
   //do something with values

}

patientType is always passed as “”; however, edCenterID is posted and received just fine.

If I change this from an Ajax.BeginForm to an HTML.BeginForm, everything works perfectly.

Is the problem in my DropDownList, my controller, both?

ADDED FROM COMMENTS

@Eoin pointed out to me that my select is rendering without a value and that is probably the problem. That brings up two questions:
1. Why does it work with the a standard post, but not an Ajax post.
2. How do I get my dropdownlist to contain a value with the list is a simple string only list (no key). I am posting the code used to generate my SelectList below

ViewData["PatientTypeList"]=new SelectList(new List<string>() 
        { "Referral", "Patient"});
  • 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-11T18:59:31+00:00Added an answer on May 11, 2026 at 6:59 pm

    Does the patientType List have a .Value

    By the looks of things, theres no value being rendered for the PatientType DDL <option>‘s so essentially every option has a value=”” so it is actually post back the correct value.

    The problem is with what’s being rendered in the first place.

    edit

    Try

    Dictionary<string, string> d = new Dictionary<string, string>();
    d.Add("referral", "referral");
    d.Add("patient", "patient");
    
    ViewData["PatientTypeList"]=new SelectList(d, "Key", "Value");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following form in a partial view @model PartDetail @using (Ajax.BeginForm(Create, Part,
I have the following code in a partial view: @model MyOrganization.MyApp.Models.ProductListing @using (Ajax.BeginForm(TagProduct, new
I have the following form: <li> <% using (Html.BeginForm(TestMethod, MyController, FormMethod.Post, new {id =
I am successfully posting a form via ajax, using the following code; $.post( Page.do?source=ajax,
In the following code, I'm using Ajax.BeginForm to post data to the action asynchronously.
Here is my View: @using (Ajax.BeginForm(Accept, FriendRequest, new { id = m.FriendRequest.Id }, new
In my html I have <h2>Title goes here</h2> @using (Html.BeginForm(Action, Controller, FormMethod.Post, new {
I'm using the following form as part of an Advanced Search page on my
What are the performance, security, or other implications of using the following form to
I am using the following code for my form validation. The code is working

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.