Ok, so I am working on a project where inside a RadWizard control I am adding dynamically creating RadDropDownList controls.
RadDropDownList ddl = new RadDropDownList() { ID = string.Format("FrmDDL{0}", i) };
I then call a method to select the selected RadDropDownListItem (Now using every method I can think of to select the value) (The RadDropDownList is passed to the method as 'r')
foreach (DropDownListItem l in r.Items)
{
if (string.Compare(value, l.Value) == 0)
{
l.Selected = true;
r.SelectedIndex = i;
r.SelectedValue = l.Value;
r.SelectedText = l.Text;
}
i++;
}
Now where it gets interesting is when you look at the generated code
<div id="FrmDDL0" class="RadDropDownList" style="width:300px;" tabindex="0">
<span class="rddlInner">
<span class="rddlFakeInput">X4</span>
<span class="rddlIcon"><!-- --></span>
</span>
<div class="rddlSlide" id="FrmDDL0_DropDown" style="display:none;">
<div class="rddlPopup rddlPopup_SI">
<ul class="rddlList">
<li class="rddlItem"> </li>
<li class="rddlItem">X1</li>
<li class="rddlItem">X2</li>
<li class="rddlItem">X3</li>
<li class="rddlItem rddlItemSelected">X4</li>
</ul>
</div>
</div>
<input id="FrmDDL0_ClientState" name="FrmDDL0_ClientState" type="hidden" autocomplete="off">
</div>
You can clearly see that the _ClientState control is not populated with the selected value even though the <li> item has the 'rddlItemSelected' class. For comparison this is what it looks like if I selected a value from the RadDropDownList from the UI.
<input id="FrmDDL0_ClientState" name="FrmDDL0_ClientState" type="hidden" autocomplete="off" value="{"enabled":true,"logEntries":[],"selectedIndex":4,"selectedText":"X4","selectedValue":"X4"}">
So the question really becomes, when using the RadWizard and its back and forward buttons, how do I persist client selection on a dynamically created RadDropDownList