protected void Page_Load(object sender, EventArgs e) { administracionProducto producto = new administracionProducto(); DataTable dt = new DataTable(); dt = producto.listaProductos(); StringBuilder sb = new StringBuilder(); sb.Append("<table>"); foreach (DataRow dr in dt.Rows) { sb.Append("<tr>"); foreach (DataColumn dc in dt.Columns) { sb.Append("<td>"); sb.Append(dr[dc.ColumnName].ToString()); sb.Append("</td>"); } sb.Append("</tr>"); } sb.Append("</table>"); string tabla = sb.ToString(); }
protected void btnAgregarProducto_Click(object sender, EventArgs e) { try { Producto prodTemporal = new Producto(); administracionProducto admProducto = new administracionProducto(); prodTemporal.nombreProducto = txtNombreProducto.Text; prodTemporal.precioProducto = Convert.ToInt32(txtPrecioProducto.Text); prodTemporal.marca = ddlMarca.SelectedValue; prodTemporal.imagenProducto = admProducto.imageToByte(inputImagenProducto.FileName); prodTemporal.ventaMin = Convert.ToInt32(txtVentaMinima.Text); prodTemporal.ventaMax = Convert.ToInt32(txtVentaMaxima.Text); prodTemporal.idRubro = Convert.ToInt32(ddlRubro.SelectedValue); prodTemporal.idLote = Convert.ToInt32(ddLote.SelectedValue); prodTemporal.idSubFamilia = Convert.ToInt32(ddlSubFamilia.SelectedValue); admProducto.agregarProducto(prodTemporal); limpiarCampos(); lblMensaje.Text = "Producto " + txtNombreProducto.Text + " agregado con éxito."; } catch (Exception ex) { lblMensaje.Text = ex.Message; } }