I'm in need of help because I'm making a website where: I show the values of the DB lines and I have the option of updating the data via the Web.
When I try to upgrade it gives me the following error:
Description: Unhandled exception when running the current Web request. See the stack trace for more information about the error and its source point in the code.
Exception Details: System.ArgumentException: Can not set a null value for the 'Salary' column. Instead, use DBNull.
The code excerpt is this:
protected void Grid2_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
GridViewRow r1 = Grid2.Rows[e.RowIndex];
rtrab = tabtrab.FindById((int)Grid2.DataKeys[e.RowIndex].Value);
if (rtrab != null)
{
rtrab["Salario"] = ((TextBox)r1.FindControl("TxtSalario"));
}
Grid2.EditIndex = -1;
adpt1 = new tb_trabalhadorTableAdapter();
adpt1.Update(tabtrab);
adpt1.Filltrabalhador(tabtrab);
enchegrid();
}
The error line is this:
{
rtrab["Salario"] = ((TextBox)r1.FindControl("TxtSalario"));
}