I populate a ddlFrequency dropdownlist from a table, set the text and now just want to get it's corresponding value.
The drop down list - 2 entries:
ddlFrequency.SelectedItem.Text = "Daily"
This line of code:
ddlFrequency.SelectedItem.Text = "Daily";
does not select the item with the value
2. Instead, it modifies the text of the currently selected item (by default, it would be the first item), setting it to "Daily". Both items would then have the same text, but different values.
You can select the item with the text "Daily" this way:
ddlFrequency.Items.FindByText("Daily").Selected = true;
or, as I prefer to do, set the selected value:
ddlFrequency.SelectedValue = "2";
which can then be retrieved with the same property:
string value = ddlFrequency.SelectedValue;