Update BD Website

Asked

Viewed 49 times

0

I need help because I’m making a website where : I show the values of the BD lines and have the option to update the data via Web.

When I try to update it gives me the following error:

Description: Unprocessed exception when executing the current web request. See stack tracking for more information about the error and its source point in the code.

Exception Details: System.Argumentexception: Unable to set a null value for Column 'Salario'. Instead, use Dbnull.

The code snippet 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"));
    }
  • ((Textbox)R1.Findcontrol("Txtsalario")) is returned null, try checking the value before arrow in the field

  • ((Textbox)R1.Findcontrol("Txtsalario"). Text; when I use text I put . Text and if it is only integer values I put something to replace the text ?

  • No, @Chrisadler. You’ll have to convert the value to number.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.