How can i fix this error? c# asp linq

Gussy Rodriguez

A few minutes ago this part of my code was functional with success, few minutes after i see this when i compile the project

Error image result

And the code is:

    string Cat = ddlCategoria.SelectedValue;
    int? MaxIdCat = (from p in db.tblProducto
                     where p.IdCategoria == Cat
                     select p.IdProducto).Max() + 1;

    txtIdEmp.Text = Convert.ToString(MaxIdCat ?? +1);
karthik krishnasamy

Please make sure Cat is having value in variable and as well as in table. If that value is not existing in table you have to handle is null on the entire linq query.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related