protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        int index = Convert.ToInt32(e.CommandArgument);

        GridViewRow filaSeleccionada = this.GridView1.Rows[index];

        TableCell celdaIDProducto = filaSeleccionada.Cells[2];

        if (e.CommandName == "Seleccionar")
        {
            Response.Redirect("EditarRegistro.aspx?ProductoID=" + celdaIDProducto.Text);
        }
        else if (e.CommandName == "Eliminar")
        {
            this.nuevaConexion = new ConexionDesconectada();
            this.nuevaConexion.copiarBaseDatos();
            if (this.nuevaConexion.eliminarProducto(int.Parse(celdaIDProducto.Text)) < 1)
            {
                ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "error_msg", "alert('Error al eliminar el producto');", true);
            }
            else
            {
                nuevaConexion.desconectar();
                Response.Redirect("Default.aspx");
            }
        }
    }
Esempio n. 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        conexion = new ConexionDesconectada();

        if (!IsPostBack)
        {
            conexion.copiarBaseDatos();
            this.conexion.llenarCombo(ref this.CategoryID, "Categories", "CategoryID", "CategoryName");
            this.conexion.llenarCombo(ref this.SupplierID, "Suppliers", "SupplierID", "CompanyName");
            conexion.desconectar();
        }
    }