protected void Button1_Click(object sender, EventArgs e) { NCategoria categoria = new NCategoria(); categoria.Nombre1 = TextBox1.Text; categoria.Descripcion1 = TextBox2.Text; categoria.Guardar(); }
protected void Page_Load(object sender, EventArgs e) { if (HttpContext.Current.User.Identity.Name != "")//si esta logueado { ncategoria = new NCategoria(); if (Request.QueryString["Id"] != null) //si esta con parametros { if (!IsPostBack) { int i = System.Convert.ToInt32(Request.QueryString["Id"]); DCategoria c = ncategoria.ObtenerCategoria(i); TextBox3.Text = c.Id1.ToString(); TextBox1.Text = c.Nombre1; TextBox2.Text = c.Descripcion1; ImageButton2.Visible = true; } } else { ide.Visible = false; } } else { Redireccion("Login.aspx"); } }
void CargarCategorias() { ncategoria = new NCategoria(); List<DCategoria> l = ncategoria.ObtenerCategorias(); String comilla = "\""; String s = ""; String bg = "fcfcfc"; foreach (DCategoria element in l) { if (bg == "fcfcfc") { bg = "eaeaea"; } else { bg = "fcfcfc"; } s = s + "<tr> <td valign= height="+comilla+"100px "+comilla+"top" + comilla + " bgcolor=" + comilla + bg + comilla + " class=" + comilla + "Bodycelda" + comilla + "><a href=" + comilla + "Categoria.aspx?id="+element.Id1.ToString() + comilla + ">" + element.Nombre1 + "</a></td> <td valign=" + comilla + "top" + comilla + " bgcolor=" + comilla + bg + comilla + " class=" + comilla + "Bodycelda" + comilla + ">"+element.Descripcion1+"</td> <td valign=" + comilla + "top" + comilla + " bgcolor=" + comilla + bg + comilla + " class=" + comilla + "Bodycelda" + comilla + ">185</td> </tr>"; } //nuevo s = s + "<tr> <td valign= height=" + comilla + "100px " + comilla + "top" + comilla + " bgcolor=" + comilla + bg + comilla + " class=" + comilla + "Bodycelda" + comilla + "><a href=" + comilla + "#" + comilla + "></a></td> <td valign=" + comilla + "top" + comilla + " bgcolor=" + comilla + bg + comilla + " class=" + comilla + "Bodycelda" + comilla + "></td> <td align=" + comilla + "right" + comilla + " valign=" + comilla + "top" + comilla + " bgcolor=" + comilla + bg + comilla + " class=" + comilla + "Bodycelda" + comilla + "><a href="+comilla+"Categoria.aspx"+comilla+"><IMG SRC = " + comilla + "../images/NUEVO.png" + comilla + "></a></td> </tr>"; Categorias.Text = s; }