Basically i have two panel control under a dropdownlist.within those panel also have a dropdownlist. now i can enter the data from dropdownlist1 to database. But don't know how to enter data from those dropdownlist under panel into database.
please help me....
here's my cs code
protected void select_ctgry(object sender, EventArgs e)
{
if (DropDownList6.SelectedValue.ToString() == "Luxury")
{
Panel1.Visible = true;
Panel2.Visible = false;
Panel3.Visible = false;
}
else if (DropDownList7.SelectedItem.ToString() == "SUV")
{
Panel1.Visible = false;
Panel2.Visible = true;
Panel3.Visible = false;
}
else
{
Panel1.Visible = false;
Panel2.Visible = false;
Panel3.Visible = true;
}
}
protected void click_insert(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["carrental"].ConnectionString);
SqlCommand cmd = new SqlCommand();
try
{
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "insert into car_insert (city,loc,c_type,email,date,time) values(@city,@loc,@c_type,@email,@date,@time)";
cmd.Parameters.AddWithValue("@city", DropDownList1.SelectedItem.Text.ToString());
cmd.Parameters.AddWithValue("@loc", DropDownList2.SelectedItem.Text.ToString());
cmd.Parameters.AddWithValue("@loc",DropDownList3.SelectedItem.Text.ToString());
cmd.Parameters.AddWithValue("@c_type", DropDownList5.SelectedItem.Text.ToString());
cmd.Parameters.AddWithValue("@email", TextBox2.Text.ToString());
cmd.Parameters.AddWithValue("@time",DropDownList4.SelectedItem.Text.ToString());
con.Open();
cmd.ExecuteNonQuery();
con.Close();
Response.Redirect("showdata.aspx");
}
catch (Exception ex)
{ Response.Write(ex.Message); }
}
}
}