Click here to Skip to main content
15,879,535 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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); }
}
}
}
Posted
Comments
[no name] 13-Jun-14 21:14pm    
What do you mean "you don't know how"? You have code here so you must know how. After all, you did not ask a question or tell us about any problem.
Debanjan Mondal 13-Jun-14 21:48pm    
yes,i have the code....suppose if i choose "suv" car type,then the car name from the dropdownlist and the car type will enter in database.i can enter the cartype but what about car name?
I guess you have dat inside the panel. So, get from there.
[no name] 14-Jun-14 8:14am    
Okay so what about the car name? Do you think that it's remotely possible that we can't see your screen to know what it is that you see? Nor can we read your mind. Why are you unable to copy/paste the error message that you are getting here?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900