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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:59:31+00:00 2026-05-28T07:59:31+00:00

I have two combobox. I need get some value from first combobox1 after combobox1

  • 0

I have two combobox. I need get some value from first combobox1 after combobox1 has changed value and that put this value in Combobox2 route

databinding.Ajax().Select(“action”,”controller”,–>route<<-)

    @(Html.Telerik()
.ComboBoxFor(m => m.Country)
.ClientEvents(e => e.OnChange"onCountryChange"))
.BindTo(Model.ListCountry))

    @(Html.Telerik()
.ComboBoxFor(m => m.UnitOfAdministration)
.ClientEvents(e => e.OnChange("onCityChange"))
.BindTo(Model.ListUnitOfAdministration)
.DataBinding(bind => 
bind.Ajax().Select("GetCityListByStr", "User",new { idCountry = "in this place i need put curent country ID" })
.Delay(1000))

function onCountryChange(e) {   
    var fildUnit =  $("#fild_UnitOfAdministration");
    var fildStreet = $("#fild_Street").hide();
    var fildHouse = $("#fild_House").hide();
    var fildSegmentHouse = $("#fild_SegmentHouse").hide();
    var curCountry = Number(e.value);
    if(curCountry.toString() == "NaN" || curCountry==0){
        fildUnit.hide();
    }else{
    $.post("@(Url.Action("GetCityList", "User"))", { id:curCountry, asd:Math.random() },
         function (data) {                   
                    fildUnit.show();
                    var comboBox = $('#UnitOfAdministration').data('tComboBox');    
        comboBox.dataBind(data);
                    comboBox.select(0);                     
         });
}
}

    [HttpPost]
    public ActionResult GetCityList(string id)
    {

        int _id = id.ExtractID();
        ViewData["curCountry"] = _id;
        List<SelectListItem> listSel = new List<SelectListItem>();
        listSel.Add(new SelectListItem() { Text = "Виберіть місто", Value = "0", Selected = true });
        TUnitOfAdministration un = TUnitOfAdministration.GetObject(_id);
        if (un != null)
        {
            string sql = "lft>" + un.Lft + " AND RGT<" + un.Rgt + " AND TypeUnit in (2,3) order by Name";
            TypedBindingList list = TUnitOfAdministration.GetObjects(sql);
            foreach (TUnitOfAdministration item in list)
            {
                listSel.Add(new SelectListItem { Text = item.Name, Value = item.ID.ToString() });
            }
        }
        return new JsonResult { Data = new SelectList(listSel, "Value", "Text", 0) };
    }
[HttpPost]
    public ActionResult GetCityListByStr(string text,string idCountry) 
    {
        text = text.ClearStringFull();
        int _idCountry = idCountry.ExtractID();
        List<SelectListItem> listSel = new List<SelectListItem>();
        TypedBindingList list = new TypedBindingList(typeof(TUnitOfAdministration));
        listSel.Add(new SelectListItem() { Text = "Виберіть місто", Value = "0", Selected = true });
        TUnitOfAdministration country = TUnitOfAdministration.GetObject(_idCountry);
        if (country != null)
        {
            string sqlAll = "ID_UnitOfAdministration = " + country.ID_UnitOfAdministration + "  AND Name like '" + text + "%' Order by name";
            list = TUnitOfAdministration.GetObjects(sqlAll);

            //if (list.Count == 0)
            //{
            //  string sql = "lft>" + country.Lft + " AND RGT<" + country.Rgt + " AND TypeUnit in (2,3) order by Name";
            //  list = TUnitOfAdministration.GetObjects(sql);
            //}

            foreach (TUnitOfAdministration item in list)
            {
                listSel.Add(new SelectListItem { Text = item.Name, Value = item.ID.ToString() });
            }
        }
        return new JsonResult { Data = new SelectList(listSel, "Value", "Text", 0) };
    }

Thanks in advance.

  • 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-28T07:59:31+00:00Added an answer on May 28, 2026 at 7:59 am

    You could fetch it from the current RouteData:

    new { curentCountry = ViewContext.RouteData.Values["countryID"] }
    

    where countryID is the name of the route parameter you are using. Or if it was part of the query string and not part of your routes:

    new { curentCountry = Request["countryID"] }
    

    You may take a look at the documentation which illustrates how you could subscribe to the OnDataBinding event which is raised when a request to fetch data is being made:

    So you could subscribe to the OnDataBinding event:

    @(Html.Telerik()
          .ComboBoxFor(m => m.UnitOfAdministration)
          .ClientEvents(e => e.OnDataBinding("onComboBoxDataBinding"))
          .BindTo(Model.ListUnitOfAdministration)
          .DataBinding(bind => bind.Ajax().Select("GetCityListByStr", "User")
          .Delay(1000)
    )
    

    and which allows you to pass additional arguments to this request

    <script type="text/javascript">
        function onComboBoxDataBinding(e) {
            e.data = $.extend({ }, e.data, { curentCountry: "customValue"});
        }
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SL DataGrid that has two columns. I need to be able
I have two identical tables and need to copy rows from table to another.
I have some logic in the business layer that limits the ComboBox options according
I currently have two comboboxes on a form. The first combobox contains a list
I am using extjs combobox for a sex field. It have two value M
I have two list that I load when my app starts. The first one
I have two dependent combo-boxes and the value of second one is populated after
How far is the code for best functionallity? I have two ComboBox, so the
I have two related ComboBoxes ( continents, and countries ). When the continents ComboBox
I have two applications written in Java that communicate with each other using XML

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.