I want to fill a radioButtonList control with the result of a SELECT statement from another radioButtonList control.
Here is the code: (my error follows)
CODE
protected void radioListManufacturers_SelectedIndexChanged(object sender, EventArgs e)
{
//get the manufacturer that the user selected
string manufSelect = radioListManufacturers.SelectedValue.ToString();
Label1.Text = manufSelect;
//Run a SELECT statement to get all the model names,
//that match the manufacturer selected
MySqlConnection conn = new MySqlConnection(DataAccessClass.GetConnectionString("AFPConnection"));
MySqlCommand com = conn.CreateCommand();
com.CommandType = CommandType.Text;
com.CommandText = "SELECT DISTINCT modelname FROM basevehicle WHERE(manufacturer = ?vManu)";
com.Parameters.Add
("?vManu", MySqlDbType.VarChar).Value = manufSelect;
//create dataset
DataSet dsModels = new DataSet();
//dataAdapter
MySqlDataAdapter adapter = new MySqlDataAdapter();
adapter.SelectCommand = com;
//fill dataset
adapter.Fill(dsModels);
//tell radiobuttonlist where the info is and bind it
radioListModels.DataSource = dsModels;
radioListModels.DataBind();
//tell the gridview where the info is and bind it
GridView1.DataSource = dsModels;
GridView1.DataBind();
}
In the preceding code my GridView1 presents the correct info eg:
CODE
modelname
--------------
Rodeo
but the radioList presents this info
System.Data.DataRowView So it seems to work but I get the wrong info for the radioList.
It should present "Rodeo".
I think I'm binding to the wrong info..?
How can I rectify this? Any help would be great.
Thanks!