protected void UserSignUpButton_Click(object sender, EventArgs e) { if (MultiView2.GetActiveView() == UserSignUp) { MultiView2.SetActiveView(emptyView); } else { MultiView2.SetActiveView(UserSignUp); } using (SqlConnection connection = new SqlConnection(connectionString)) { SqlCommand command = new SqlCommand("EXEC ListAllCities", connection); connection.Open(); SqlDataReader reader = command.ExecuteReader(); userCityList.DataSource = reader; userCityList.DataTextField = "Name"; userCityList.DataValueField = "ID"; userCityList.DataBind(); } using (SqlConnection connection = new SqlConnection(connectionString)) { UserDistrictList.Items.Clear(); SqlCommand command = new SqlCommand("EXEC ListAllDistrictsWithCity " + userCityList.SelectedItem.Value, connection); connection.Open(); SqlDataReader reader = command.ExecuteReader(); UserDistrictList.DataSource = reader; UserDistrictList.DataTextField = "Name"; UserDistrictList.DataValueField = "ID"; UserDistrictList.DataBind(); } }
protected void UserCityList_SelectedIndexChanged(object sender, EventArgs e) { using (SqlConnection connection = new SqlConnection(connectionString)) { UserDistrictList.Items.Clear(); SqlCommand command = new SqlCommand("EXEC ListAllDistrictsWithCity " + userCityList.SelectedItem.Value, connection); connection.Open(); SqlDataReader reader = command.ExecuteReader(); UserDistrictList.DataSource = reader; UserDistrictList.DataTextField = "Name"; UserDistrictList.DataValueField = "ID"; UserDistrictList.DataBind(); } }