I have a combobox with three items:
Toyota
Kia
Hyndai
Then I have a small table with two columns (Marks and Models):
Marks | Modelos
Toyota: Camry
Toyota: Celica
Toyota: Corolla
Kia: Optima
Kia: Picanto
Kia: Sportage
Hyundai: Accent
Hyundai: Azera
Hyundai: Elantra
When I select one mark. What happening? I found in the combobox model the table's name repeted in that combobox:
string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\rentacar\rentacar\\app_data\rentacar.mdb;Persist Security Info=False";
OleDbConnection sqlCon = new OleDbConnection(connectionString);
sqlCon.Open();
string commandString = "select * from carsconfig where cars ='" + cbxMarkConfig.Text + "'";
OleDbCommand sqlCmd = new OleDbCommand(commandString, sqlCon);
OleDbDataReader read = sqlCmd.ExecuteReader();
if (read.HasRows)
{
while (read.Read())
{
cbxModelsConfig.Items.Add("models"); // it will show the code
}
}
else
{
MessageBox.Show("A record with a code of " + cbxMarkConfig.Text + " was not found");
}
}
}
Joginder BangerPosted Nov 24, 2014, 5:07 AM
IsraelPosted Nov 24, 2014, 5:02 AM
Joginder BangerPosted Nov 24, 2014, 4:46 AM
protected void Page_Load(object sender, EventArgs e){
if (!IsPostBack)
{
binddropdown();
}
}
public void binddropdown()
{
}
and second question:
create a event of combobox selectedINDEX.
On this event bind another combobox same as it is.