Hi,
assigning of Value should not be dependable on the time, when your dropdown list values are generated.
The Value is assigned when the control is generated therefore you need to assigne it into some variable. Please take a look at following example:
private string mValue;
public override Object Value
get
{
return ddl.SelectedValue;
}
set
{
mValue = ValidationHelper.GetString(value, null);
ddl.SelectedValue = mvalue;
}
protected void Page_Load(object sender, EventArgs e)
{
if (dropDownList.Items.Count == 0)
{
// LOAD ITEMS
...
ddl.SelectedValue = mvalue;
}
}
How to add dropdown list into custom form control is described in appropriate section of
devguide as well.
Best regards,
Ivana Tomanickova