Tuesday, September 24, 2013

gridview edit

lblAddCountry.Text = "";
            GridView gvCountry= (GridView)sender;
            iCompanyId = Int32.Parse(gvCountry.DataKeys[Int32.Parse(e.NewEditIndex.ToString())].Values["ID"].ToString());
            strName=gvCountry.DataKeys[Int32.Parse(e.NewEditIndex.ToString())].Values["Name"].ToString();
            strCode=gvCountry.DataKeys[Int32.Parse(e.NewEditIndex.ToString())].Values["CountryCode"].ToString();
            txtAddCountry.Text = strName;
            txtAddCountryCode.Text = strCode;
            iStatus = 1;
            Session["strStatus"] ="U";
            Session["iCompanyId"] = iCompanyId;
            btnAddCountry.Text = "Update";


DELETE

 GridView gvCountry = (GridView)sender;
            int iCountryId = (int)gvCountry.DataKeys[e.RowIndex].Values["ID"];


Select

 protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
        {
            int id = (int)GridView1.DataKeys[e.NewSelectedIndex].Values["id"];
        }

No comments: