Reputation: 63
A few minutes ago this part of my code was functional with success, few minutes after i see this when i compile the project
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);
Upvotes: 4
Views: 73
Reputation: 46
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.
Upvotes: 3