protected void btnEdit_Click(object sender, EventArgs e) { LinkButton btnAdd = sender as LinkButton; GridViewRow gvr = (GridViewRow)btnAdd.NamingContainer; int index = gvr.RowIndex; int idProd = 0; string Nombre = ""; string Color = ""; string Desc = ""; string Contenido = ""; string Precio = ""; try { int.TryParse(gvProductos.DataKeys[index]["Código"].ToString(), out idProd); Nombre = gvProductos.DataKeys[index]["Nombre"].ToString(); Color = gvProductos.DataKeys[index]["Color"].ToString(); Contenido = gvProductos.DataKeys[index]["Contenido"].ToString(); Precio = gvProductos.DataKeys[index]["Precio"].ToString(); Desc = gvProductos.DataKeys[index]["Descripción"].ToString(); dsProductos.dtProductoDataTable dt = new dsProductos.dtProductoDataTable(); dt.Rows.Add(idProd, Nombre, Color, Contenido, Precio, Desc); Session["dtProductosEdit"] = dt; Response.Redirect("ModProducto.aspx"); } catch { } }
protected void Page_Load(object sender, EventArgs e) { oProductoBO = new ProductoBO(); oProductoDAO = new ProductoDAO(); if (Session["dtProductosEdit"] != null && !IsPostBack) { dsProductos.dtProductoDataTable dt = (dsProductos.dtProductoDataTable)Session["dtProductosEdit"]; foreach (DataRow dr in dt.Rows) { txtId.Value = dr["Código"].ToString(); txtNombreP.Text = dr["Nombre"].ToString(); txtColor.Text = dr["Color"].ToString(); txtContenido.Text = dr["Contenido"].ToString(); txtPrecio.Text = dr["Precio"].ToString(); txtDescripcionP.Text = dr["Descripción"].ToString(); } } }