protected void SubmitButton_Click(object sender, EventArgs e) { da = new SqlDataAdapter("insert into Transport_Details(T_Type,T_category,T_Name,To_Country,To_City,From_Country,From_City,Date,Time,Amount,Description)values('" + typeDropDownList.SelectedItem.Text + "','" + DropdownCategory.SelectedItem.Text + "','" + NameTextBox.Text + "','" + DropDownToCountry.SelectedItem.Text + "','" + DropDownToCity.SelectedItem.Text + "','" + DropDownFromCountry.SelectedItem.Text + "','" + DropDownFromCity.SelectedItem.Text + "','" + TextBox1.Text + "','" + TimeTextBox.Text + "'," + AmtTextBox.Text + ",'" + DescTextBox.Text + "')", con); dt = new DataTable(); da.Fill(dt); Label2.Text = "Data Sumbmit"; TextBox1.Text = ""; DropdownCategory.ClearSelection(); DropDownToCountry.ClearSelection(); DropDownToCity.ClearSelection(); DropDownFromCountry.ClearSelection(); DropDownFromCity.ClearSelection(); NameTextBox.Text = ""; typeDropDownList.ClearSelection(); TimeTextBox.Text = ""; AmtTextBox.Text = ""; DescTextBox.Text = ""; da = new SqlDataAdapter("select T_Id,T_Type,T_Category,T_Name,To_Country,To_City,From_Country,From_City,convert(varchar,Date,106)Date,Time,Amount,Description from Transport_Details order by T_Id DESC", con); dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count > 0) { GridViewTransportDetails.DataSource = dt; GridViewTransportDetails.DataBind(); } else { GridViewTransportDetails.DataSource = ""; GridViewTransportDetails.DataBind(); } }
protected void DropDownToCountry_SelectedIndexChanged(object sender, EventArgs e) { if (DropDownToCountry.SelectedIndex > 0) { da = new SqlDataAdapter("select CityName from CountryCityMaster where CountryName='" + DropDownToCountry.SelectedItem.Text + "' order by CityName", con); dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count > 0) { DropDownToCity.DataSource = dt; DropDownToCity.DataTextField = "CityName"; DropDownToCity.DataBind(); DropDownToCity.Items.Insert(0, "Select City"); DropDownToCity.Items.Insert(dt.Rows.Count + 1, "Other City"); } else { DropDownToCity.DataSource = ""; DropDownToCity.DataBind(); DropDownToCity.Items.Insert(0, "Select City"); } } else { DropDownToCity.DataSource = ""; DropDownToCity.DataBind(); DropDownToCity.Items.Insert(0, "Select City"); } }