سلام
یه فرم رزرو دارم که میخوام شماره میز و نام غذا بر اساس رستورانی که انتخاب میکنم نمایش داده بشه ولی هر کدی مینویسم نمیشه
اینم کدم ممنون میشم راهنماییم کنید protected void DropDownList_restaurant_SelectedIndexChanged(object sender, EventArgs e) { string cs = ConfigurationManager.ConnectionStrings["cs"].ConnectionString; SqlConnection sqlcon = new SqlConnection(cs); SqlCommand command = new SqlCommand(" SELECT * FROM desk WHERE restaurant_code = @restaurant_code", sqlcon); command.Parameters.AddWithValue("@restaurant_code", DropDownList_restaurant.SelectedIndex); if (sqlcon.State != ConnectionState.Open) { sqlcon.Open(); } SqlDataReader dr = command.ExecuteReader(); DropDownList_tablecode.DataSource = dr; DropDownList_tablecode.DataTextField = "desk_code"; DropDownList_tablecode.DataValueField = "desk_code"; DropDownList_tablecode.DataBind(); DropDownList_tablecode.Items.Insert(0, new ListItem("انتخاب کنید")); if (sqlcon.State != ConnectionState.Closed) sqlcon.Close(); } protected void DropDownList_tablecode_SelectedIndexChanged(object sender, EventArgs e) { string cs = ConfigurationManager.ConnectionStrings["cs"].ConnectionString; SqlConnection sqlcon = new SqlConnection(cs); SqlCommand command = new SqlCommand(" SELECT * FROM food WHERE restaurant_code = @restaurant_code", sqlcon); command.Parameters.AddWithValue("@restaurant_code", DropDownList_restaurant.SelectedIndex); if (sqlcon.State != ConnectionState.Open) { sqlcon.Open(); } SqlDataReader dr = command.ExecuteReader(); DropDownList_food.DataSource = dr; DropDownList_food.DataTextField = "food_name"; DropDownList_food.DataValueField = "food_code"; DropDownList_food.DataBind(); DropDownList_food.Items.Insert(0, new ListItem("انتخاب کنید")); if (sqlcon.State != ConnectionState.Closed) sqlcon.Close(); }
هیچ کاربری تا کنون از این پست تشکر نکرده است
با ما تماس بگیرید تا در این مسیر همراهتان باشیم :)