예제 #1
0
 protected void Btn_DistrictView_Click(object sender, EventArgs e)
 {
     getcon();
     if (DropDown_DistrictCountry.SelectedIndex > 0)
     {
         if (DropDown_DistrictState.SelectedIndex > 0)
         {
             Lbl_DistrictState.Visible = false;
             string         str1 = "select district_name,district_id from tbl_district where state_id='" + DropDown_DistrictState.SelectedItem.Value + "'";
             SqlCommand     cmd1 = new SqlCommand(str1, con);
             SqlDataAdapter ad1  = new SqlDataAdapter(cmd1);
             DataTable      dt1  = new DataTable();
             ad1.Fill(dt1);
             if (dt1.Rows.Count > 0)
             {
                 Grd_District.DataSource = dt1;
                 Grd_District.DataBind();
             }
         }
         else
         {
             Lbl_DistrictState.Visible = true;
         }
     }
     con.Close();
 }
예제 #2
0
        protected void Grd_District_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
        {
            getcon();
            Grd_District.EditIndex = -1;
            string         str2 = "select district_name,district_id from tbl_district where state_id='" + DropDown_DistrictState.SelectedItem.Value + "'";
            SqlCommand     cmd2 = new SqlCommand(str2, con);
            SqlDataAdapter ad2  = new SqlDataAdapter(cmd2);
            DataTable      dt2  = new DataTable();

            ad2.Fill(dt2);
            if (dt2.Rows.Count > 0)
            {
                Grd_District.DataSource = dt2;
                Grd_District.DataBind();
            }
            con.Close();
        }
예제 #3
0
        protected void Grd_District_RowEditing(object sender, GridViewEditEventArgs e)
        {
            Grd_District.EditIndex = e.NewEditIndex;
            getcon();
            string         str = "select district_name,district_id from tbl_district where state_id='" + DropDown_DistrictState.SelectedItem.Value + "'";
            SqlCommand     cmd = new SqlCommand(str, con);
            SqlDataAdapter ad1 = new SqlDataAdapter(cmd);
            DataTable      dt  = new DataTable();

            ad1.Fill(dt);
            if (dt.Rows.Count > 0)
            {
                Grd_District.DataSource = dt;
                Grd_District.DataBind();
            }
            con.Close();
        }
예제 #4
0
        protected void Grd_District_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            getcon();
            string     dk  = Grd_District.DataKeys[e.RowIndex].Values[0].ToString();
            string     str = "delete from tbl_district where district_id='" + dk + "'";
            SqlCommand cmd = new SqlCommand(str, con);

            cmd.ExecuteNonQuery();
            string         str1 = "select district_name,district_id from tbl_district where state_id='" + DropDown_DistrictState.SelectedItem.Value + "'";
            SqlCommand     cmd1 = new SqlCommand(str1, con);
            SqlDataAdapter ad   = new SqlDataAdapter(cmd1);
            DataTable      dt1  = new DataTable();

            ad.Fill(dt1);
            if (dt1.Rows.Count > 0)
            {
                Grd_District.DataSource = dt1;
                Grd_District.DataBind();
            }
            con.Close();
        }