I had a dropdown where on dropdown change event I retrieved the
values from db and populated to textboxex accordingly on
selection of dropdownlistitem but finding difficult to get the
value from db and populate radiobuttonlist item checked exactly
I had an edit page where I had
few textboxes and 1 radiobuttonlist where if i go to edit page i had
adropdown on dropdown selected list item I need to retrieve the data
from db and populate textboxes and populated radiobuttonlist item checked(which matches the string in db)
{
string ConnectionString = ConfigurationManager.ConnectionStrings["PizzaDelievery"].ConnectionString;
using (SqlConnection connection = new SqlConnection(ConnectionString))
{
String strQuery = "select DriverID, DriverName,AssignedSkills from Skills where DriverID =@DriverID";
SqlCommand cmd = new SqlCommand();
cmd.Parameters.AddWithValue("@DriverID", Driver_Namedropdwn.SelectedItem.Value);
cmd.CommandType = CommandType.Text;
cmd.CommandText = strQuery;
connection.Open();
cmd.Connection = connection;
string selectedval = radioskills.SelectedValue;
SqlDataReader sdr = cmd.ExecuteReader();
while (sdr.Read())
{
Driver_Id.Text = sdr["DriverID"].ToString();
Drivername.Text = sdr["DriverName"].ToString();
if (radioskills.Items.FindByValue(sdr["AssignedSkills"].ToString()) != null)
{
radioskills.SelectedItem.Value = sdr["AssignedSkills"].ToString();
}
}
}