1
Good,
I need a little help because I’m building a web page that shows BD data on a grid.
I put the Update and delete button.
I managed to change the BD via the web. 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 have to create this one where deletes 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 erase the line at once.
That was my mistake. Thank you. I tried to delete the line this way but it gives me a bug in Customers. So I can delete only the line I want ? protected void Grid_rowdeleting(Object Sender, Gridviewdeleteeventargs e) { tb_functionsTableAdapter.Customers.Rows[0]. Delete(); enchegrid(); } }
– ChrisAdler
What’s wrong with what? I don’t see your code.. And I put the last Dit so I get very confused. tb_functionsTableAdapter is what? is a right Object? and where you have the delete and update... tu commands in this function you can know which Row q you clicked.. another example: https://www.codeproject.com/Questions/252190/Row-Deleting-event-in-gridview-control debug and ve q values you have at each step.
– sir_ask
I can not debug because it gives me error in the code in Customers. It is underlined
– ChrisAdler