我在用:
if (RadioButtonList_VolunteerType.SelectedItem != null)
或者怎么样:
if (RadioButtonList_VolunteerType.Index >= 0)
或者怎么样(根据安德鲁黑尔的回答):
if (RadioButtonList_VolunteerType.Index > -1)
对于可能阅读此问题的人,以下方法不是有效的方法。正如 Keltex 指出的那样,所选值可能是一个空字符串。
if (string.IsNullOrEmpty(RadioButtonList_VolunteerType.SelectedValue))