Problem with input autocomplete

Posted by: byron.ghislain on 9 September 2021, 8:22 pm EST

    • Post Options:
    • Link

    Posted 9 September 2021, 8:22 pm EST

    Hi, I try to add a input autoComplete in my partial view. But, I have a problem with this.


        List<Programs> ListPrograms = ViewBag.ListProgram;

    Can you help me?


  • Posted 13 September 2021, 6:48 pm EST


    We apologize for the delay in response, To resolve the above issue, we may cast the data from ViewBag to IEnumerable before passing it to the bind() method of AutoComplete control.

    Please refer to the below code snippet:

        var data = as IEnumerable<InputControl.Models.Country>;

    Please refer to the sample below.


  • Posted 14 September 2021, 10:21 pm EST

    Thank you, I try this. And I need to change for take this value for add on my model for save with httppost?


  • Posted 14 September 2021, 10:44 pm EST

    In my console, I have a status 500

  • Posted 15 September 2021, 7:17 pm EST


    If you wish to bind the value to the model and send the selectedValue from the partialView back to the controller, you may use modelBinding and use Form to post the values back to the Server.

    If the above implementation doesn’t fulfill your requirement. Kindly let us know along with your usecase scenario and screenshot of the error displayed.

    Please refer to the updated sample below.


  • Posted 15 September 2021, 11:57 pm EST


    View index

        	var data = ViewBag.ListProgram as IEnumerable<Record.Models.Programs>;
    @using (Html.BeginForm())
    	@(Html.C1().AutoCompleteFor(model => model.Name).Id("ProgramsID").SelectedValuePath("ProgramsID").Bind(data).DisplayMemberPath("Name"))


    public ActionResult Add()
                if (Request.IsAjaxRequest())
                       ViewBag.ListProgram = GetEnumProgramsList();
                    Timers timerss = new Timers();
                    timerss.StartDate = DateTime.Now;
                    timerss.EndDate = DateTime.Now.AddHours(1);
                    timerss.Active = true;
                    return PartialView(timerss);
                Response.StatusCode = 500;
                return PartialView("Error");
  • Posted 17 September 2021, 1:01 am EST

    Apparently, my problem is because my autocomplete is in a partial view… I change for use “Chaining Combos” but the problem is the same.

    If I put the exemple of the index view. No problem, if I put in my partial view… My partial view is in a modal div


  • Posted 19 September 2021, 3:36 am EST

    Hi, We apologize but we are unable to replicate the issue at our end. We have used the single AutoComplete. We do not know how you have implemented the Chaining Combobox and you are facing the issue. Please refer to the attached sample which shows the AutoCompelet into the modal popup using the Partial View and it works fine.

    Regards, Manish Gupta

  • Posted 19 September 2021, 6:17 pm EST

    If I use In my controller

    ViewBag.ListPrograms = programsModel.Select(x => new SelectListItem(){ Value = x.ProgramsID.ToString(), Text = x.Name });

    In my partial view

        var dataPrograms = ViewBag.ListPrograms as IEnumerable<Programs>;
    @(Html.C1().AutoCompleteFor(m => m.Programs.Name).Id("AutoCompleteProgram").SelectedValuePath("Name").Bind(dataPrograms).DisplayMemberPath("Name").CssMatch("hightlight"))

    And the bind doesn’t work

  • Posted 20 September 2021, 8:58 pm EST


    We apologize but we are unable to replicate the issue at our end with the above-provided code snippet.

    Kindly provide a sample depicting the issue or make changes in the below sample, so that we may debug it and reply accordingly.

    Regards Dushyant Sharma

  • Posted 20 September 2021, 9:09 pm EST

    I think the problem is with Entity Framework… I don’t know why but if I put a bind. Blank page…

  • Posted 22 September 2021, 7:11 pm EST


    There might be some issue in fetching data using Entity Framework like the fetched data could be proxies of instances rather than actual instances which would cause the given issue.

    Kindly refer to the below thread for more information on the above issue:

    Regards Dushyant Sharma

  • Posted 22 September 2021, 8:12 pm EST

    ok thank you

    But I would like to save the id of the autocomplete input.


    why it s not possible? I would like to save the ID in my object

  • Posted 23 September 2021, 5:25 pm EST


    To pass the ProgramId along with the ProgramName to the server, we may attach a hidden input element in the form and may bind it with the above parameter (ProgramId).

    Once the value is selected in the autoComplete control, we may update the value of the hidden field before submitting the form.

    Please refer to the sample below.

    Regards Dushyant Sharma

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels