This is a migrated thread and some comments may be shown as answers.

while page loads dropdown control shows selected value.

1 Answer 538 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Vikas
Top achievements
Rank 1
Vikas asked on 11 Aug 2016, 08:39 PM

Hi

While page refreshes and reloads, DropDown list shows Drop Down's selected value in a textbox. Though Once page is loaded it is all fine. But for our purpose it is not desirable to show value that dropdown is binded to. If it had shown the selected text it would have been ok. We also don't want to hide the drop down untill page is ready and show it.

 I dont see it is a performance issue as well since i created a seperate view and had only dropdown control in the entire view. Have provided sample code that you can execute to test the behavior

@model ViewModels.DdlVM

@using (@Html.BeginForm())
{
@(Html.Kendo().DropDownListFor(m => m.ddlprop)
                            .DataTextField("Text")
                            .DataValueField("Value")
                            .BindTo(Model.ddlOptions )
                            )
<input type="submit"
value="save" />
}

namespace ViewModels
{

  public class DdlVM
    {    public List<SelectListItem> ddlOptions { get; set; }

     public string ddlprop{ get; set; }

}

}

controller

  public ActionResult ClickMe()
        {
            DdlVM testvm = new DdlVM();
            testvm.ddlOptions = new List<SelectListItem>();
            for (int i = 0; i < 100; i++)
            {
                testvm.ddlOptions.Add(new SelectListItem()
                {
                    Text = "TAB- " + i.ToString(),
                    Value = i.ToString()
                });
            }
            return View("TestClickMe", testvm);
        }
        [HttpPost]
        public ActionResult ClickMe(DdlVM testvm)
        {
            testvm.DelimiterOptions = new List<SelectListItem>();
            for (int i = 0; i < 100; i++)
            {
                testvm.ddlOptions.Add(new SelectListItem()
                {
                    Text = "TAB- " + i.ToString(),
                    Value = i.ToString(),
                    Selected = testvm.ddlprop== i.ToString()
                });
            }
            return View("TestClickMe", testvm);
            #endregion
        }

 

1 Answer, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 15 Aug 2016, 03:29 PM

Hello Vikas,

Does the autoBind:false setting work for your case? It will not show the selected value until user opens the DropDownList. 

Regards,
Boyan Dimitrov
Telerik by Progress
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
Tags
DropDownList
Asked by
Vikas
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Share this question
or