I have a RadioButtonList that is populated from a database, users need to at least check / select one of RadioButtons. How can I make sure they check / choose RadioButton? I tried many different ways, but no luck, here is my code. I also try to warn them about turning off the radio.
I am trying to verify that the RadioButtonList is checked / selected.
if (cblstatus.SelectedItem.Value == "1") { //Create Category con.Open(); SqlCommand departament = new SqlCommand("insert into categories(ca_name, ca_number, ca_status, ca_department, ca_date, ca_time, ca_user) " + "values('" + category.Text + "', '" + number.Text + "', 'Y', '" + catdepartment.SelectedValue + "', '" + date + "', '" + time + "', '" + user + "')", con); departament.ExecuteNonQuery(); con.Close(); } else if (cblstatus.SelectedItem.Value == "2") { //Create Category con.Open(); SqlCommand departament = new SqlCommand("insert into categories(ca_name, ca_number, ca_status, ca_department, ca_date, ca_time, ca_user) " + "values('" + category.Text + "', '" + number.Text + "', 'N', '" + catdepartment.SelectedValue + "', '" + date + "', '" + time + "', '" + user + "')", con); departament.ExecuteNonQuery(); con.Close(); } else if (cblstatus. == null) { alert.InnerHtml = "<div id=\"warning\" class=\"message warning\">Warning! Please select a department.</div>" + "<script>" + "setTimeout(function () { $('#success').fadeOut(); }, 2000);" + "</script>"; }
source share