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

The Archive Base Latest Questions

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

i´m new developing on asp.net mvc, and even newer using jquery, so this is

  • 0

i´m new developing on asp.net mvc, and even newer using jquery, so this is my problem: i have a few dropdown list that are filled dinamically using the data of another dropdown or textbox, and the data of those drop down is used for another drop down, like a chain, my problem rigth now is that the dropdown sometimes just have one answer/option, and if i try to select that option jquery doesn´t activate the $(“#anything”).change() event, ’cause i have just one option, how i handle it?

http://imageshack.us/photo/my-images/20/sinttulolp.jpg/

for example this i need the data of the red circle for filling the blue circle, but the red circle just have one option and if i click nothing happens

code:

$(document).ready(function() {

            $("#tbClave1").autocomplete({
                minLength: 1,
                source: getClave1,
                select: function(event, ui) {
                    updateClave2(ui.item.value);

                }
            });

            $("#tbClave1").change(function() {
                if ($("#tbClave1").val().length == 4) {
                    updateClave2($("#tbClave1").val());
                }
            });

            $("#ddClave2").change(function() {
                updateClave3($("#tbClave1").val(), $("#ddClave2").val());
                updateNombre($("#tbClave1").val(), $("#ddClave2").val());
                if ($("#ddTipoArticulo").val() == "A" ||
                    $("#ddTipoArticulo").val() == "B" ||
                    $("#ddTipoArticulo").val() == "L") {
                    updatePrecioA($("#tbClave1").val(), $("#ddClave2").val());
                } else { 
                    if ($("#ddTipoArticulo").val() == "N" ||
                         $("#ddTipoArticulo").val() == "H"){
                         updatePrecioB($("#tbClave1").val());
                    }
                }
            });

            $("#ddClave3").change(function() {
                updateClave4($("#tbClave1").val(), $("#ddClave2").val(), $("#ddClave3").val());
            });
        });

Edit: example of how i fill one of the dropdownlist

Jquery

function updateClave2(cod) {

            var dd = document.getElementById("ddClave2");
            dd.options.length = 0;
            dd.options[0] = new Option("Espere...");
            dd.selectedIndex = 0;
            dd.disabled = true;
            codigo = cod;
            tipoArt = $("#ddTipoArticulo").val();
            // Control de errores
            $("#ddClave2").ajaxError(function(event, request, settings) {
                dd.options[0] = new Option("No se Cargaron Datos");
            });
            // Obtenemos los datos...
            $.ajax({
                url: '/Home/GetClave2',
                dataType: 'json',
                data: { words: codigo, tipoArticulo: tipoArt },
                success: function(data, textStatus, jqXHR) {
                    $.each(data, function(i, item) {
                        dd.options[i] = new Option(item["clave2"], item["clave2"]);
                    });
                    dd.disabled = false;
                }
            });
        }

Controller

public ActionResult GetClave2(string words, string tipoArticulo){
List mySource = miConexion.Clave2(username, password, words, tipoArticulo);
return Json(mySource);
}

  • 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-30T16:59:52+00:00Added an answer on May 30, 2026 at 4:59 pm

    As Alex Mendez has wrote, adding a default item to each dropdownlist with text like “Select One” seems to be your easiest answer. You’ll also need to do some handling in case the user re-selects the default “Select One option.” To add default values to your .Net dropdowns try out this code:

    YourListID.Items.Insert(0, new ListItem("Select One", "Select One");
    

    or:

    <asp:DropDownList ID="YourListID" runat="server" AppendDataBoundItems="true">
        <asp:ListItem Text="Select One" Value="Select One" Selected="true" />
    </asp:DropDownList>
    

    EDIT (Missed the MVC)
    and in MVC when you bind your initial ViewData just make sure to have your “Select One” in the liest:

    Dictionary<int, string> dictionaryList = DropDownListItems();
    ViewData["ModelData"] = new SelectList(dictionaryList, "Key", "Value")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm interested in using Subsonic 3.0 for developing a new ASP.Net MVC application that
I'm developing a web application using ASP.NET MVC (I'm new to the framework and
I've been developing a site using ASP.NET MVC, and have decided to use the
I'm new to developing web apps using ASP.NET MVC. In fact, I'm rather new
I'm new to the jQuery and ASP.Net MVC. I'm developing a mvc application which
I am new to JQuery. I am developing a ASP.Net MVC application. In one
I'm developing a new ASP.NET MVC 2.0 application and wanting to use the new
I am developing an asp.net MVC web app in which I am using Linq
I am new to linq and asp.net mvc and right now i am developing
Good Morning All, I am developing a new ASP.net MVC web application. Part of

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.