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!
Thank you. Your solution worked for me.
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
There is a bug with the latest version. You can set the .CurrentValue="" property during Pre-Render and that will clear the value for you.