Good,
I need a little help because I'm building a webpage where it shows the DB data in a Grid.
I put the Update button and delete.
I got through the web to make change to DB. But I'm having trouble deleting the line.
protected void ligabd()
{
adpt = new tb_funcoesTableAdapter();
tabfun = new DataSet.tb_funcoesDataTable();
// tabfun = adpt.GetData();
adpt.Fill(tabfun);
}
protected void enchegrid()
{
Grid.DataKeyNames = new string[] { "Id" };
Grid.DataSource = tabfun;
Grid.DataBind();
}
protected void Grid_RowEditing(object sender, GridViewEditEventArgs e)
{
Grid.EditIndex = e.NewEditIndex;
enchegrid();
}
protected void Grid_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
Grid.EditIndex = -1;
enchegrid();
}
protected void Grid_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
GridViewRow r = Grid.Rows[e.RowIndex];
rfun = tabfun.FindById((int)Grid.DataKeys[e.RowIndex].Value);
if (rfun != null)
{
rfun["funcao"] = ((TextBox)r.FindControl("txtfuncao")).Text;
}
Grid.EditIndex = -1;
adpt = new tb_funcoesTableAdapter();
adpt.Update(tabfun);
adpt.Fill(tabfun);
enchegrid();
}
I leave here some of my code. Now I'm missing to create this one where it erases the complete line. I have the following code and it is giving error:
protected void Grid_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
tb_funcoesTableAdapter.Customers.Rows[0].Delete();
enchegrid();
}
Thanks for any help that makes me realize how I can delete the line at once.