protected void grdcategory_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                //if( )
                //{

                //}
                #region command name = delete

                //else
                if (e.CommandName == "Delete")
                {
                    string Id            = Convert.ToString(e.CommandArgument);
                    int    Issuccessfull = objedit.deleteItemsCategory(Convert.ToString(Id));
                    bindItemsCategory();
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "Popup", "alertdelete()", true);
                }

                #endregion
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Popup", "errormodal()", true);
            }
        }
Пример #2
0
        protected void grdcategory_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                #region command name = edit

                if (e.CommandName == "Edit")
                {
                    var           con = new SqlConnection(strcon);
                    SqlDataReader dr;
                    string        Id = Convert.ToString(e.CommandArgument);
                    ViewState["Id"] = Id;
                    con.Open();
                    SqlCommand cmd = new SqlCommand("Select * from tblcategory where Id=@id", con);
                    cmd.Parameters.AddWithValue("@id", Id);
                    dr = cmd.ExecuteReader();
                    if (dr.Read())
                    {
                        txtcategory.Text = dr["categoryname"].ToString();
                    }
                    con.Close();
                    btnsmt.Text = "Update";
                }

                #endregion

                #region command name = delete

                else if (e.CommandName == "Delete")
                {
                    string Id            = Convert.ToString(e.CommandArgument);
                    int    Issuccessfull = objedit.deleteItemsCategory(Convert.ToString(Id));
                    bindItemsCategory();
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "Popup", "alertdelete()", true);
                }

                #endregion
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Popup", "errormodal()", true);
            }
        }