Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1740
Setting the input texbox of a multi-select WebDropDown with the values selected in the page_load
posted

My WebDropDown has multi-select checkbox enabled. I have default selection initalized (more than 2 items) in the code-behind page_load event. How do I reflect the input textbox with the selected values? It shows by default only the first item which in my case is not selected.

I tried to initialize the input textbox from javascript in the onload event but I can't access the WebDropDown using $find('WebDropDown1'). This gives me null value.

Any ideas someone!

Parents
  • 12679
    Suggested Answer
    posted

    Hello,

    I would  suggest  something like this:

       39     void WebDropDown1_PreRender(object sender, EventArgs e)

       40     {

       41         WebDropDown1.Items[2].Selected = true;

       42         WebDropDown1.Items[3].Selected = true;

       43 

       44         string currnetValue = "";

       45 

       46         foreach (DropDownItem item in WebDropDown1.Items)

       47         {

       48             if (item.Selected)

       49             {

       50                 currnetValue += item.Text+",";

       51             }

       52             if (item.Selected)

       53             {

       54               WebDropDown1.CurrentValue =

       55                     currnetValue.Substring(0, currnetValue.Length - 1);

       56             }

       57         }

       58     }

    Regards

    Rado

Reply Children
No Data