G
g
I have a user control that contains a dropdownlist. Using a public
property, I can get the selected item. However, I am unsure of how to use
that same public property to set the selected item. Here's my code:
private string m_item = "";
public string Item
{
get
{
m_item = this.dropdownlist.SelectedValue;
return m_item;
}
set
{
m_item = value;
// How to set the selected value/item in the dropdownlist
this.dropdownlist.SelectedValue = m_item; // Doesn't work...
}
}
property, I can get the selected item. However, I am unsure of how to use
that same public property to set the selected item. Here's my code:
private string m_item = "";
public string Item
{
get
{
m_item = this.dropdownlist.SelectedValue;
return m_item;
}
set
{
m_item = value;
// How to set the selected value/item in the dropdownlist
this.dropdownlist.SelectedValue = m_item; // Doesn't work...
}
}