When i click on the page that represents a controller the following error was displayed:-
"The null value cannot be assigned to a member with type System.Int32 which is a non-nullable value type"
On this link of code
var articleapproval = articletyperepository.FindAllArticlesRequireMyApproval().ToList(); while the FindAllArticlesRequireMyApproval execute the following LINQ statement :- var articleapproval= articletyperepository.FindAllArticlesRequireMyApproval().ToList();
where this methods calls the following LINQ statement:-
I'm currently stuck with a problem with MVC2 RC and validation on a dropdownlist :
I have a page with some fields and a dropdownlist. The dropdownlist is not a mandatory field so I would like to save a null value into my property.
Unfortunately, I can't validate my page with a null selected value, because when I look into the modelstate just on the first line of my action, I've already an error telling me I must choose an item.
Is it normal working of dropdownlist validation or is it a bug ?
I am making a website to store invoices so i can mail them to clients. So i got a table for clients, invoices and one with invoice products/services. When an invoice has no products/services added to them and it returns null i get the error "the null value cannot be assigned to a member with type System.Decimal which is a non-nullable value type."
I just started with linq. Before i always used mysql. Mostly i just had to call data from 1 table so forgive me if my linq query isn't really correct.
Dim invoices = From i In db.invoices _ Group Join p In db.products On i.id Equals p.invoiceId Into invoiceProducts = Group _ Select New With {i.client.naam, i.titel, (From iP In invoiceProducts Select iP.prijs).Sum}
i show the client's name, the title of the invoice and the total amount the clients will need to pay for products and services.
I am LINQ querrying against a datatable. However, I am unsuccessfull with catching null values. Here is my code that is giving me the following error.
[Code]....
I am checking to see if minperc is null. However to check that it still is trying to convert the value to double. Cant figure out a way around it. Here is the error: Cannot cast DBNull.Value to type 'System.Double'. Please use a nullable type.
I remember being told that you can add some syntax to the end of a statement that will do something if the field is null. Pretty vague, but I cant seem to find anything about it via google.
I definitely isnt how to set a field to be nullable. I know that.
Here is an example of what I want.
int? field1 = 0;
field1 = int.parse(string2); (where string2 is a passed value, that could be null)
I thought there was something you could put at ?? if it is a null, such as:
field1 = int.parse(string2) ??;
Or do I have to check every if every string2 is null before making that statement.
Can anyone reliably get the EDS to save a nullable column to the databse as a "null" when bound to any of the controls such as "FormView"?I have tried using several different UpdateParameters (Session, ControlParamater, Parameter, etc). I have tried setting "ConvertEmptyStringToNull" to true and leaving the property off entirely. Nothing works. On my "Inserts" it works fine.(I have made sure the column is set to nullable = true in the Entity Designer.....)
Got a nullable datetime member on my viewmodel.the moment it hit my controller action, the viewmodel's modelstate allready are invalid (because the member is null).Forgot...how that works? (using MVC2)Basically my viewmodel have a social security number, passport number and passport expiracy date.If the ssn is entered, I want to ignore the two passport related fields, so I made the expiracy date member nullable.
Like all other viewmodels in this app, each model have it's own validation function that will do validation, and in there I add an error that the date is required or not valid (if using passport number). mvc itself should not care about the date at all.I dont want to give the date a default value, because then the date will show when the form loads, and it must be an empty field (unless I already got a date of course.
I have to change the username column in my database to nullable, which means everywhere in my code, I now have to check username.HasValue and change references to username to username.Value. Is there anything I can do to avoid having to change all the references to username to username.Value?
[System.Web.Script.Services.ScriptService] public class Quotes : System.Web.Services.WebService { ebMethod] public void Calculate(int param1, int? param2)
I'm trying to bind a nullable bit column, which at the moment is mostly null, but I need to somehow convert the null to a 'false' on runtime because it doesn't bind to a checkbox if it's null. But, I am currently unable to change the default value and update all records accordingly - is there a way to do this in runtime?
I'm trying to write a query that will work in two situations. In some situations the value for AOL will be Null and in others there will be a vnumeric value. How do I get this procedure to accept Null if its passed in but also accept a numeric value if it's passed in?
I have a javascript to validate and avoid null values for my form but there are some textboxes that I need to be 'optional'. I tried erasing the validation for province address and province contact in javascript to make it optional, but the problem is whenever I add the values in the database, an error message appears "Input string was not in a correct format". It's in C# This is my present code wherein the provincial address and provincial contact must only be optional:
Am I going to be able to query (using LINQ to SQL) a database field with a type like the following "public System.Nullable<System.DateTime> Spouse_DOB"?
I'm trying to use the following code: [Code]....
and I get the error "'System.Nullable<System.DateTime>' does not contain a definition for 'Month' and no extension method 'Month' accepting a first argument of type 'System.Nullable<System.DateTime>' could be found (are you missing a using directive or an assembly reference?)"
Is it because this DateTime column allows a NULL value (since everyone isn't married in my database)?
Error 1 'System.Nullable<System.DateTime>' does not contain a definition for 'Month' and no extension method 'Month' accepting a first argument of type 'System.Nullable<System.DateTime>' could be found (are you missing a using directive or an assembly reference?) C:Working WebsitesGrannys Clan Address BookDefault.aspx.cs 38 26 C:Working WebsitesGrannys Clan Addres
Iīm creating a user page to enable editing their profiles. When hitting the "update" button, it turns out that the field still contains the old value, although youīre looking at the new one, ie the text property of the textbox isnīt the value of the parameter which in fact gets its value from the text property.As far as I know I havenīt done anything I havenīt done before, both in apps and website?
i am using a search box for my application which returns a dataset. however when i click on the search button it returns an empty table result. how could i add validation so it doesnt accept empty strings or numbers.
I need to validate integer within a specified range for English and French culture. The integer contains group separator ("," in English culture or " " in French culture). It seems I can't do it with RangeValidator on my machine.
I just want to make sure the RangeValidator can't do this kind validation for Integer before I'm going to write my own control.
I just feel curious because RangeValidator can actually do this kind of validation for Currency!
I have an invoice form where user enters items and amount. I am calculating the amount as the user enters amount in the textfield. I receive an error (Input String was not in correct format) if user enters amount with comma separated values. If there are no commas, my calculation goes through fine.
I have the below stored procedure witch has an error I cann't figure out.
What I want: Gets rankOrder. If rankOrder doesn't have a value (= null) the @num should be insertet as 1 as value. If there is a row and a rankOrder is should set the @num to insert the value + 1. The last one works perfect. But when the row I select is emty = null value the value is set to null in the insert command.
I was trying to read a data of a Job stream using a System.Printing name space, from a default print queue. I can get all the job info, like number of pages, but the JobStream data is always null, is there a solution for that? or is it broken or a bug. Here is my code
foreach (PrintSystemJobInfo Job in defaultPrintQueue.GetPrintJobInfoCollection())