protected void Button1_Click(object sender, EventArgs e) { CityManager cityManager = new CityManager(); City city = new City(); city.CityName = TextBox1.Text; city.About = TextBox2.Text; city.NumberOfDwellers = Convert.ToInt32(TextBox3.Text); city.Location = TextBox4.Text; city.Weather = TextBox5.Text; city.CountryId = Convert.ToInt32(countryDropDownList.SelectedValue); showStatusLabel.Text = cityManager.SaveCity(city); Clear(); }
protected void Page_Load(object sender, EventArgs e) { CityManager cityManager = new CityManager(); GridView1.DataSource = cityManager.ShowCountryCity(); GridView1.DataBind(); CountryManager countryManager = new CountryManager(); if (!IsPostBack) { countryDropDownList.DataTextField = "CountryName"; countryDropDownList.DataValueField = "CountryId"; countryDropDownList.DataSource = countryManager.ShowCountry(); countryDropDownList.DataBind(); } }
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { CityManager cityManager = new CityManager(); GridView1.DataSource = cityManager; GridView1.DataBind(); }