Is there a way to determine (after a postback) if a value in a dropdownlist has been added dynamically or is one of the initial values?
eg.
<asp:DropDownList ID="MyDDL" runat="server">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
</asp:DropDownList>
// on postback 1
private void AddExtraItemToList()
{
if (someCondition) // extra items may or may not be inserted
MyDDL.Items.Add("17");
}
// on postback 2
private void RemoveExtraItemsFromList()
{
// remove any non-default values from the list... ?
}
It's obvioulsy trivial to do by coding a list of default values in code behind or something, but it would be neat if you could do the above by querying which values were intial properties and which were generated from viewstate restoration.