我想将三个不同的下拉列表值绑定到数据库中的单个列中。
protected void BookNow_Click(object sender, EventArgs e)
{
//Session["Date"]=ddlDate.SelectedItem+ ddlMonth.SelectedItem+ddlYear.SelectedItem;
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["dbconnection"].ConnectionString);
conn.Open();
string date = ddlYear.SelectedValue.ToString() + "/" + ddlMonth.SelectedValue.ToString() + "/" + ddlDate.SelectedValue.ToString();
SqlCommand cmd = new SqlCommand(@"insert into OnlineBookingEvent(BookingEvent,BookeventDate,cdt,udt)values
(@BookingEvent,@BookeventDate,@cdt,@udt)", conn);
cmd.Parameters.AddWithValue("@BookingEvent", ddlEventName.SelectedItem);
cmd.Parameters.AddWithValue("@BookeventDate",date);
cmd.Parameters.AddWithValue("@cdt", System.DateTime.Now);
cmd.Parameters.AddWithValue("@udt", System.DateTime.Now);
cmd.ExecuteNonQuery();
}