protected void btnGravar_Click(object sender, EventArgs e) { Impressora imp = new Impressora(); imp.nome_impressora = txbNomeImpressora.Text; imp.tipo = ddlTipo.SelectedValue; imp.descricao_impressora = txbDescricao.Text; imp.ip_impressora = txbIp.Text; string mensagem = ImpressoraDAO.GravaImpressora(imp.nome_impressora, imp.tipo, imp.descricao_impressora, imp.ip_impressora); ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + mensagem + "');", true); ClearInputs(Page.Controls);// limpa os textbox }
protected void GridView1_PreRender(object sender, EventArgs e) { // colocar no grid OnPreRender="GridView1_PreRender" // You only need the following 2 lines of code if you are not // using an ObjectDataSource of SqlDataSource GridView1.DataSource = ImpressoraDAO.ListaImpressora(); GridView1.DataBind(); if (GridView1.Rows.Count > 0) { //This replaces <td> with <th> and adds the scope attribute GridView1.UseAccessibleHeader = true; //This will add the <thead> and <tbody> elements GridView1.HeaderRow.TableSection = TableRowSection.TableHeader; //This adds the <tfoot> element. //Remove if you don't have a footer row GridView1.FooterRow.TableSection = TableRowSection.TableFooter; } }