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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:55:16+00:00 2026-06-18T02:55:16+00:00

I have dropdown list which display data from the database. I get database data

  • 0

I have dropdown list which display data from the database. I get database data in drop down list but after selecting value in drop down list the selected value I want to pass in controller, then I want to display all detail data of that selected value. But clicking on submit button the selected value of dropdown list is not getting passed to controller.

this is my code

View: Index.aspx

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<ApricaCRMEvent.Models.CRM.DatabaseEntities.CRM_Doctor_Request>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    SearchIndex
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<h2>SearchIndex</h2>

    <%--<div id = "SelectDoctors">
          <% Html.RenderPartial("SelectDoctors"); %> 
    </div>--%>
    <script type="text/javascript">
        function TestFun() {
            var mdlno = $("#ddlMDLNo").val();
//            $.getJSON("/SearchMDLNo/getMDLNoDetails/" + mdlno, null, function (data) {

//                alert(data.Request_For_Id);
//            });
            var txtmdlno = document.getElementById("Request_For_Id");
            txtmdlno.value = mdlno;
            alert(txtmdlno.value);
        }
</script>

<div>
<h2>Search by MDLNo</h2>
     <% using (Html.BeginForm())
        { %>

         <%: Html.ValidationSummary(true, "Profile Updation was unsuccessful. Please correct the errors and try again.") %>

        Select MDLno 

        <%= Html.DropDownList("ddlMDLNo", ViewData["MDLno"] as SelectList, "--Select One--", new { onchange = "TestFun()" })%> 
        <%: Html.TextBoxFor(m => m.Request_For_Id)%>       

         <input type="submit" value="search" name="SearchMDLNo" />    
    <% } %>
</div>


<div> <% Html.RenderPartial("ListDoctors"); %></div>

</asp:Content>

Controller: SearchMDLNoController.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ApricaCRMEvent.Models.CRM.DataLayer;
using ApricaCRMEvent.Models.CRM.DatabaseEntities;

namespace ApricaCRMEvent.Controllers
{
    public class SearchMDLNoController : Controller
    {
        CRM_Doctor_Request mdlnoObj = new CRM_Doctor_Request();

        public ActionResult Index()
        {
            ViewData["MDLno"] = new SelectList(SearchMDLNoDL.getAllMDLno(), "Request_For_Id", "Request_For_Id");
            return View();
        }

        [HttpPost]
        public ActionResult Index(CRM_Doctor_Request model)
        {
            ViewData["MDLno"] = new SelectList(SearchMDLNoDL.getAllMDLno(), "Request_For_Id", "Request_For_Id");

            //CRM_Doctor_Request mdlnoObj = SearchMDLNoDL.getMDLData("GJ04_D023");
            //mdlnoObj = SearchMDLNoDL.getMDLData(model.Request_For_Id);
            return View();
        }
        public ActionResult getMDLNoDetails(string id)
        {
            mdlnoObj=SearchMDLNoDL.getMDLData(id);
            return View();
        }
        public ActionResult ListDoctors()
        {
            return View(mdlnoObj);
        }

    }
}

this is partial view and in this view selected drop down value .. detail data will be display

partical View : ListDoctors.ascx

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ApricaCRMEvent.Models.CRM.DatabaseEntities.CRM_Doctor_Request>" %>


<div><%: Html.DisplayFor(m => m.Request_For_Id) %></div>

<div>
<table>
    <tr>
        <th>
            Request_For_Id
        </th>
        <th>
            Territory
        </th>
        <th>
            Estimated_Amount
        </th>
        <th>
            Actual_Amount
        </th>
        <th>
            Date_Created
        </th>
        <th>
            Compute_CRM_State
        </th>
        <th>
            Compute_Event_Type
        </th>

    </tr>


    <tr>
        <td>
            <%: Html.DisplayFor(m => m.Request_For_Id) %>
        </td>
        <td>
            <%: Html.DisplayFor(m => m.Territory) %>
        </td>
        <td>
            <%: Html.DisplayFor(m => m.Estimated_Amount) %>
        </td>
        <td>
            <%: Html.DisplayFor(m => m.Actual_Amount) %>
        </td>
        <td>
            <%: Html.DisplayFor(m => m.Date_Created) %>
        </td>
        <td>
            <%: Html.DisplayFor(m => m.Compute_Service_State) %>
        </td>
        <td>
            <%: Html.DisplayFor(m => m.Compute_Event_Type) %>
        </td>
      </tr>


</table>

</div>

by selecting value in drop down list and clicking on submit button value is not getting passed. In Index.aspx I have tried some javascript code but it does not work.


I have changed something in code. And now this is working.

View: Index.aspx

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<ApricaCRMEvent.Models.CRM.DatabaseEntities.CRM_Doctor_Request>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    SearchIndex
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<h2>SearchIndex</h2>

    <%--<div id = "SelectDoctors">
          <% Html.RenderPartial("SelectDoctors"); %> 
    </div>--%>
    <script type="text/javascript">
        function TestFun() {
            var mdlno = $("#ddlMDLNo").val();

            var txtmdlno = document.getElementById("Request_For_Id");
            txtmdlno.value = mdlno;
            alert(txtmdlno.value);

        }
</script>

<div>
<h2>Search by MDLNo</h2>
     <% using (Html.BeginForm())
        { %>

         <%: Html.ValidationSummary(true, "Profile Updation was unsuccessful. Please correct the errors and try again.") %>

        Select MDLno 

        <%= Html.DropDownList("ddlMDLNo", ViewData["MDLno"] as SelectList, "--Select One--", new { onchange = "TestFun()" })%> 
        <%: Html.TextBoxFor(model => model.Request_For_Id) %>

         <input type="submit" value="search" name="SearchMDLNo" />    
    <% } %>
</div>


<%--<div> <% Html.RenderPartial("ListDoctors"); %></div>--%>
<div>
    <fieldset>
    <legend>CRM_Doctor_Request</legend>

    <div class="display-label">Territory</div>
    <div class="display-field">
        <%: Html.DisplayFor(model => model.Territory) %>
    </div>

    <div class="display-label">CRM_Request_For_Type_Id</div>
    <div class="display-field">
        <%: Html.DisplayFor(model => model.CRM_Request_For_Type_Id) %>
    </div>

    <div class="display-label">Request_For_Id</div>
    <div class="display-field">
        <%: Html.DisplayFor(model => model.Request_For_Id) %>
    </div>

    <div class="display-label">Requestor</div>
    <div class="display-field">
        <%: Html.DisplayFor(model => model.Requestor) %>
    </div>

    <div class="display-label">Division_Id</div>
    <div class="display-field">
        <%: Html.DisplayFor(model => model.Division_Id) %>
    </div>

    <div class="display-label">Suggester</div>
    <div class="display-field">
        <%: Html.DisplayFor(model => model.Suggester) %>
    </div>

    <div class="display-label">Estimated_Amount</div>
    <div class="display-field">
        <%: Html.DisplayFor(model => model.Estimated_Amount) %>
    </div>

    <div class="display-label">Actual_Amount</div>
    <div class="display-field">
        <%: Html.DisplayFor(model => model.Actual_Amount) %>
    </div>

    <div class="display-label">Priority</div>
    <div class="display-field">
        <%: Html.DisplayFor(model => model.Priority) %>
    </div>

    <div class="display-label">CRM_Service_Type_Id</div>
    <div class="display-field">
        <%: Html.DisplayFor(model => model.CRM_Service_Type_Id) %>
    </div>

    <div class="display-label">Deadline</div>
    <div class="display-field">
        <%: Html.DisplayFor(model => model.Deadline) %>
    </div>

    <div class="display-label">Executed_Date</div>
    <div class="display-field">
        <%: Html.DisplayFor(model => model.Executed_Date) %>
    </div>

    <div class="display-label">Entry_Done_By</div>
    <div class="display-field">
        <%: Html.DisplayFor(model => model.Entry_Done_By) %>
    </div>

    <div class="display-label">Date_Created</div>
    <div class="display-field">
        <%: Html.DisplayFor(model => model.Date_Created) %>
    </div>

    <div class="display-label">Date_Modified</div>
    <div class="display-field">
        <%: Html.DisplayFor(model => model.Date_Modified) %>
    </div>

    <div class="display-label">Event_Type_Id</div>
    <div class="display-field">
        <%: Html.DisplayFor(model => model.Event_Type_Id) %>
    </div>

    <div class="display-label">Compute_Event_Type</div>
    <div class="display-field">
        <%: Html.DisplayFor(model => model.Compute_Event_Type) %>
    </div>

    <div class="display-label">CRM_State_Id</div>
    <div class="display-field">
        <%: Html.DisplayFor(model => model.CRM_State_Id) %>
    </div>

    <div class="display-label">Compute_CRM_State</div>
    <div class="display-field">
        <%: Html.DisplayFor(model => model.Compute_CRM_State) %>
    </div>

    <div class="display-label">Service_State_Id</div>
    <div class="display-field">
        <%: Html.DisplayFor(model => model.Service_State_Id) %>
    </div>

    <div class="display-label">Compute_Service_State</div>
    <div class="display-field">
        <%: Html.DisplayFor(model => model.Compute_Service_State) %>
    </div>

    <div class="display-label">Is_Active</div>
    <div class="display-field">
        <%: Html.DisplayFor(model => model.Is_Active) %>
    </div>

    <div class="display-label">Comment</div>
    <div class="display-field">
        <%: Html.DisplayFor(model => model.Comment) %>
    </div>
</fieldset>


</div>
</asp:Content>

Controller: SearchMDLNoController.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ApricaCRMEvent.Models.CRM.DataLayer;
using ApricaCRMEvent.Models.CRM.DatabaseEntities;

namespace ApricaCRMEvent.Controllers
{
    public class SearchMDLNoController : Controller
    {
        CRM_Doctor_Request mdlnoObj = new CRM_Doctor_Request();

        public ActionResult Index()
        {
            ViewData["MDLno"] = new SelectList(SearchMDLNoDL.getAllMDLno(), "Request_For_Id", "Request_For_Id");
            return View();
        }

        [HttpPost]
        public ActionResult Index(CRM_Doctor_Request model)
        {
            ViewData["MDLno"] = new SelectList(SearchMDLNoDL.getAllMDLno(), "Request_For_Id", "Request_For_Id");

            //CRM_Doctor_Request mdlnoObj = SearchMDLNoDL.getMDLData("GJ04_D023");
            //mdlnoObj = SearchMDLNoDL.getMDLData(model.Request_For_Id);
            mdlnoObj = SearchMDLNoDL.getMDLData(model.Request_For_Id);
            return View(mdlnoObj);
        }
    }
}
  • 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-18T02:55:18+00:00Added an answer on June 18, 2026 at 2:55 am

    Try this :

    $.getJSON("/SearchMDLNo/getMDLNoDetails",{id : mdlno}, function (data) {
             alert(data.Request_For_Id);
    });
    

    This should work for you


    <script type="text/javascript">
            function TestFun() {
                var mdlno = $("#ddlMDLNo").val();
                $.ajax({
                  type: 'POST',
                  dataType: 'json',
                  data: {id: mdlno},
                  success: function(result){
                          alert('success');
                  }
                });
            }
    </script>
    

    Then in your controller change it like this:

        [HttpPost]
        public ActionResult getMDLNoDetails(string id)
        {
            mdlnoObj=SearchMDLNoDL.getMDLData(id);
            return Json(true);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a drop-down list which gathers data from the database and a textbox
Afternoon All, I have a dropdown list which extracts data from my SQL database
I have a dropdown list (FK) which I would like to set and display
I have a database of Employees and a dropdown list which I generated with
I have a drop-down list which is generated based on the following sql query:
I have a drop down list which is dynamically generated using ajax on page
I have one drop down list in my page, which contains two options. What
I have code which has a drop down list. And when a certain option
I have a spinner that show my data list from a database SQLite.. I
I have a parent page which has a drop down list in it. using

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.