« DataGrid -- With Template & Total Line | Main | Custom Server Controls vs User Control »

RadioButtonList & SelectedValue

Before you want to use SelectedValue, you got to check if there is any item selected.

if(rblGrade.SelectedIndex != -1)
{
alValues.Add(rblGrade.SelectedItem.Value);
}


Before you set SelectedValue, you need to check if it is null.

if(dr["gender"] != DBNull.Value)
{
rblGender.SelectedValue = dr["gender"].ToString();
}