protected void GridView3_RowUpdating(object sender, GridViewUpdateEventArgs e) { int rowIndex = e.RowIndex; Label ID = (Label)GridView3.Rows[e.RowIndex].FindControl("Label4"); int lblID = Convert.ToInt32(ID.Text); Session["ID"] = lblID; Label Product_Name = (Label)GridView3.Rows[e.RowIndex].FindControl("Label1"); Session["P_Name"] = Product_Name.Text; DropDownList ddlStatus_edit = (DropDownList)GridView3.Rows[e.RowIndex].FindControl("DropDownList7"); string StatusName = ddlStatus_edit.SelectedItem.Value; Session["Status1"] = StatusName; if (ddlStatus_edit.SelectedItem.Value != "Under Repair" && ddlStatus_edit.SelectedItem.Value != "Warranty Under Repair" && ddlStatus_edit.SelectedItem.Value != "Replaced with FSPL Inventory and send to vendor") { try { con.Open(); string qry = "Update Product_Details set Status='" + StatusName + "', [GatePass Status]= 'Close' where ID='" + lblID + "'"; SqlCommand cmd = new SqlCommand(qry, con); cmd.ExecuteNonQuery(); con.Close(); GridView3.EditIndex = -1; populate(); } catch (Exception ex) { } //else // { // ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('FSPL Inventory doesn't have this Asset ');", true); } // } if (ddlStatus_edit.SelectedValue == "Replaced with FSPL Inventory and send to vendor") { con.Open(); using (SqlCommand comm = new SqlCommand("select [Asset_Type] from FSPL_Inventory where Asset_Type=@Asset_Type", con)) { //string Role = (string)(Session["Role"]); // 2. define parameters used in command object SqlParameter para = null; para = new SqlParameter(); para.ParameterName = "@Asset_Type"; para.Value = Product_Name.Text; comm.Parameters.Add(para); SqlDataReader reade = comm.ExecuteReader(); while (reade.Read()) { Session["Asset_Type"] = Convert.ToString(reade["Asset_Type"]); } con.Close(); } } if (Session["Asset_Type"].ToString() == null ) // ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('FSPL Inventory doesn't have this Asset ');", true); Response.Write("<script>alert('Item does not Exists in FSPL Inventory')</script>"); else { con.Open(); string qry = "Update Product_Details set Status='" + ddlStatus_edit.SelectedValue + "', [GatePass Status]= 'Close' where ID='" + ID.Text + "'"; SqlCommand cmd = new SqlCommand(qry, con); cmd.ExecuteNonQuery(); con.Close(); GridView3.EditIndex = -1; populate(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)