protected void ImgBtnEdit_Click(object sender, ImageClickEventArgs e) { lblMessage.Text = ""; List <Inv_Store> store = new List <Inv_Store>(); ImageButton imgbtn = (ImageButton)sender; GridViewRow row = (GridViewRow)imgbtn.NamingContainer; try { string StoreId = ""; Label lblstoreId = (Label)grdstore.Rows[row.RowIndex].FindControl("lblstoreId"); if (lblstoreId != null) { StoreId = lblstoreId.Text; store = aStore_BLL.GetStoreId(StoreId); if (store.Count > 0) { foreach (Inv_Store astore in store) { hdfStoreID.Value = astore.Store_Id.ToString(); txtStoreName.Text = astore.StoreName; txtStoreTrack.Text = astore.Store_Code; txtLocation.Text = astore.Location; txtDescription.Text = astore.Description; } if (BtnSave.Text == "Submit") { BtnSave.Text = "Update"; } } } } catch (Exception ex) { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('" + ex.Message + "')", true); } }