<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>ASP.NET MVC</title><link>http://forums.asp.net/1146.aspx</link><description>Discussions regarding Model-View-Controller (MVC) support in ASP.NET.  &lt;a href="http://forums.asp.net/1215.aspx"&gt;T4MVC subforum&lt;/a&gt;</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: why must I change each int/money column in Models to Nullable: True ?</title><link>http://forums.asp.net/thread/3275594.aspx</link><pubDate>Sun, 05 Jul 2009 19:29:55 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3275594</guid><dc:creator>bradwils</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3275594.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=3275594</wfw:commentRss><description>&lt;p&gt;&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="/Themes/fan/images/icon-quote.gif"&gt; &lt;strong&gt;zielony:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;
&lt;p&gt;ok thx :)&lt;/p&gt;
&lt;p&gt;Other time i will use Data Annotations when somebody add missing .dll :)&lt;/p&gt;
&lt;p&gt;&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;/p&gt;
&lt;p&gt;There are no missing DLLs. It&amp;#39;s a source code distribution. You need to open the project and build it to get the DLL.&lt;/p&gt;</description></item><item><title>Re: why must I change each int/money column in Models to Nullable: True ?</title><link>http://forums.asp.net/thread/3275582.aspx</link><pubDate>Sun, 05 Jul 2009 19:10:17 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3275582</guid><dc:creator>zielony</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3275582.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=3275582</wfw:commentRss><description>&lt;p&gt;ok thx :)&lt;/p&gt;&lt;p&gt;Other time i will use Data Annotations when somebody add missing .dll :)&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: why must I change each int/money column in Models to Nullable: True ?</title><link>http://forums.asp.net/thread/3275552.aspx</link><pubDate>Sun, 05 Jul 2009 18:03:33 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3275552</guid><dc:creator>levib</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3275552.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=3275552</wfw:commentRss><description>&lt;p&gt;You&amp;#39;re overly complicating this issue.&amp;nbsp; The reason you can&amp;#39;t compare that property to null is because the property is non-nullable.&amp;nbsp; You want to check the &lt;i&gt;user input&lt;/i&gt; for &amp;#39;empty&amp;#39;, not the property.&lt;/p&gt;
&lt;p&gt;For example, here&amp;#39;s a way to replace our default message:&lt;/p&gt;&lt;pre class="c-sharp" name="code"&gt;if (Request[&amp;quot;theField&amp;quot;] == &amp;quot;&amp;quot;) {&lt;br /&gt;    ModelState[&amp;quot;theField&amp;quot;].Errors.Clear();&lt;br /&gt;    ModelState[&amp;quot;theField&amp;quot;].Errors.Add(&amp;quot;Your custom error message here.&amp;quot;)&lt;br /&gt;}&lt;/pre&gt;
&lt;p&gt;You can also create your own custom model binder for your type.&amp;nbsp; (In fact, this is exactly why we allow you to do this in the first place.)&amp;nbsp; This might be overkill for your scenario, however.&amp;nbsp; You can find samples online for how to do this if you want to go this route.&lt;/p&gt;&lt;p&gt;Edit: Of course, using the Data Annotations model binder and [Required] will be simpler because it already encapsulates all of this logic.&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: why must I change each int/money column in Models to Nullable: True ?</title><link>http://forums.asp.net/thread/3275524.aspx</link><pubDate>Sun, 05 Jul 2009 17:18:13 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3275524</guid><dc:creator>zielony</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3275524.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=3275524</wfw:commentRss><description>&lt;p&gt;good - maybe validation will be easier in mvc 2 :)&lt;/p&gt;&lt;p&gt;Could You tell me also how I can install DataAnnotationsModelBinder if folder with these files don&amp;#39;t have System.ComponentModel.DataAnnotations.dll ?&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: why must I change each int/money column in Models to Nullable: True ?</title><link>http://forums.asp.net/thread/3275499.aspx</link><pubDate>Sun, 05 Jul 2009 16:30:03 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3275499</guid><dc:creator>bradwils</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3275499.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=3275499</wfw:commentRss><description>&lt;p&gt;You can work around this today using the DataAnnotationsModelBinder sample (by using the Required attribute with your own custom message).&lt;/p&gt;&lt;p&gt;This will be fixed in MVC 2, because it will have DataAnnotations support built-in.&lt;/p&gt;</description></item><item><title>Re: why must I change each int/money column in Models to Nullable: True ?</title><link>http://forums.asp.net/thread/3275442.aspx</link><pubDate>Sun, 05 Jul 2009 15:21:06 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3275442</guid><dc:creator>zielony</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3275442.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=3275442</wfw:commentRss><description>&lt;p&gt;I have a suggestion to people from Microsoft who create ASP.NET MVC - please give us possibility easy changing default communicate &lt;b&gt;&amp;quot;A value is required.&amp;quot;&lt;/b&gt; for empty numeric fields which are required inside controller without using Validating with the 
IErrorDataInfo Interface / Validating with Data Annotation Validators.&lt;/p&gt;&lt;p&gt;I am not only person who have this problem - see:&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.google.pl/search?hl=pl&amp;amp;q=asp.net+mvc+%22A+value+is+required.%22&amp;amp;btnG=Szukaj&amp;amp;lr="&gt;http://www.google.pl/search?hl=pl&amp;amp;q=asp.net+mvc+%22A+value+is+required.%22&amp;amp;btnG=Szukaj&amp;amp;lr=&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;For example in Symfony framework (Symfony and Zend frameworks are the most popular frameworks for php language) we also have default error communicates - BUT WE CAN SIMPLY CHENGE THEM. In ASP.NET MVC it is really too complate - please do somathing with this.&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: why must I change each int/money column in Models to Nullable: True ?</title><link>http://forums.asp.net/thread/3275394.aspx</link><pubDate>Sun, 05 Jul 2009 13:45:24 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3275394</guid><dc:creator>zielony</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3275394.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=3275394</wfw:commentRss><description>&lt;p&gt;So as I understand I have 3. options:&lt;/p&gt;&lt;p&gt;1. Make numeric columns in Models - Nullable: True &lt;/p&gt;&lt;p&gt;2. Validating with the 
IErrorDataInfo Interface&lt;b&gt;&lt;b&gt; &lt;/b&gt;&lt;/b&gt;&lt;a href="http://www.asp.net/learn/mvc/tutorial-37-cs.aspx"&gt;http://www.asp.net/learn/mvc/tutorial-37-cs.aspx&lt;/a&gt; and &lt;a href="http://www.asp.net/learn/mvc/tutorial-38-cs.aspx"&gt;http://www.asp.net/learn/mvc/tutorial-38-cs.aspx&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;3. Validating with Data Annotation Validators &lt;a href="http://www.asp.net/learn/mvc/tutorial-39-cs.aspx"&gt;http://www.asp.net/learn/mvc/tutorial-39-cs.aspx&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;I don&amp;#39;t like 2. idea - I have never seen so complicated validation. 3. idea&amp;nbsp; - no System.ComponentModel.DataAnnotations.dll in files which I downloaded so I can&amp;#39;t use it. &lt;/p&gt;&lt;p&gt;So I must use 1. idea which is stupid but simply.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: why must I change each int/money column in Models to Nullable: True ?</title><link>http://forums.asp.net/thread/3275382.aspx</link><pubDate>Sun, 05 Jul 2009 13:26:56 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3275382</guid><dc:creator>gerrylowry</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3275382.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=3275382</wfw:commentRss><description>&lt;p&gt;That could be overkill.&amp;nbsp; I do not know.&amp;nbsp; I have not used it myself.&amp;nbsp; I am not sure but I think it may only be an alpha (CTP) or Beta at this time.&amp;nbsp; That&amp;#39;s why I prefer to stick within ASP.NET MVC v1.0 which is a finished product and is supported by Microsoft.&lt;/p&gt;
&lt;p&gt;I suggest you might be better off keeping your application as simple as possible and then when it is working to your satisfaction, think about refactoring various parts of it.&lt;/p&gt;
&lt;p&gt;That is one of the selling points of ASP.NET MVC.&amp;nbsp; If you create your application correctly, you can unplug parts and plug in replacement parts and in theory it should still work and remain robust.&lt;/p&gt;
&lt;p&gt;g.&lt;/p&gt;</description></item><item><title>Re: why must I change each int/money column in Models to Nullable: True ?</title><link>http://forums.asp.net/thread/3275260.aspx</link><pubDate>Sun, 05 Jul 2009 09:56:57 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3275260</guid><dc:creator>zielony</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3275260.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=3275260</wfw:commentRss><description>&lt;p&gt;ok - I think I will try use Data Annotation Model Binder. But on this site: &lt;a href="http://www.asp.net/learn/mvc/tutorial-39-cs.aspx"&gt;http://www.asp.net/learn/mvc/tutorial-39-cs.aspx&lt;/a&gt; I see that I must select both the Microsoft.Web.Mvc.DataAnnotations.dll assembly and the 
	 System.ComponentModel.DataAnnotations.dll from downloaded folder but in this folder there isn&amp;#39;t Microsoft.Web.Mvc.DataAnnotations.dll ....&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: why must I change each int/money column in Models to Nullable: True ?</title><link>http://forums.asp.net/thread/3275223.aspx</link><pubDate>Sun, 05 Jul 2009 08:58:04 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3275223</guid><dc:creator>gerrylowry</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3275223.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=3275223</wfw:commentRss><description>&lt;p&gt;&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="/Themes/fan/images/icon-quote.gif"&gt; &lt;strong&gt;zielony:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;But is it possible to change this error in Controller without creating other class, using IDataErrorInfo ? I would like to change this errorn in my &amp;quot;if()&amp;quot;&lt;/div&gt;&lt;/BLOCKQUOTE&gt;
&lt;p&gt;zielony, try this:&amp;nbsp; set a break point at the start of your &lt;strong&gt;Controller&lt;/strong&gt;; when your code breaks, before stepping through it, check the value of the read only property &lt;strong&gt;ModelState.IsValid&lt;/strong&gt;.&amp;nbsp; If ModelState.IsValid is &lt;strong&gt;&lt;em&gt;false&lt;/em&gt;&lt;/strong&gt; before your &lt;strong&gt;Controller &lt;/strong&gt;begins execution, then you will likely have to use some form of custom approach &lt;strong&gt;&lt;em&gt;or&lt;/em&gt;&lt;/strong&gt; change your schema to allow nulls (which is a bad idea imo because your database schema rules are your last line of defense against garbage in/garbage out a.k.a. GIGO).
&lt;p&gt;&amp;nbsp;
&lt;p&gt;Regards,&lt;br /&gt;Gerry (Lowry)&lt;/p&gt;</description></item><item><title>Re: why must I change each int/money column in Models to Nullable: True ?</title><link>http://forums.asp.net/thread/3275207.aspx</link><pubDate>Sun, 05 Jul 2009 08:18:43 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3275207</guid><dc:creator>zielony</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3275207.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=3275207</wfw:commentRss><description>&lt;p&gt;But is it possible to change this error in Controller without creating partial class and using there IDataErrorInfo ? I would like to change this errorn in my &amp;quot;if()&amp;quot;&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: why must I change each int/money column in Models to Nullable: True ?</title><link>http://forums.asp.net/thread/3275192.aspx</link><pubDate>Sun, 05 Jul 2009 07:59:21 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3275192</guid><dc:creator>gerrylowry</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3275192.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=3275192</wfw:commentRss><description>&lt;p&gt;&lt;strong&gt;zielony&lt;/strong&gt;, it&amp;#39;s a flow control issue.&amp;nbsp; I can not remember the exact sequence&amp;nbsp;... &lt;/p&gt;
&lt;p&gt;I am assuming that you are creating a new book.&lt;/p&gt;
&lt;p&gt;ModelState.IsValid is a read only property.&amp;nbsp; If someone else sets it for you to invalid, you are out of luck.&lt;/p&gt;
&lt;p&gt;Line 6 of your example code.&amp;nbsp; ModelState.AddModelError will also set ModelState.IsValid to false.&lt;/p&gt;
&lt;p&gt;Have you&amp;nbsp;read these tutorials at &lt;a href="http://www.asp.net/learn/mvc/"&gt;http://www.asp.net/learn/mvc/&lt;/a&gt;?:&lt;/p&gt;
&lt;p&gt;&lt;u&gt;&lt;font color="#0066cc"&gt;&lt;strong&gt;#18 | &lt;/strong&gt;Performing Simple Validation&lt;/font&gt;&lt;/u&gt; View in &lt;a href="http://www.asp.net/learn/mvc/tutorial-36-vb.aspx"&gt;VB&lt;/a&gt; or &lt;a href="http://www.asp.net/learn/mvc/tutorial-36-cs.aspx"&gt;C#&lt;/a&gt;&amp;nbsp;&lt;br /&gt;&lt;u&gt;&lt;font color="#0066cc"&gt;&lt;strong&gt;#19 | &lt;/strong&gt;Validating with the IDataErrorInfo Interface&lt;/font&gt;&lt;/u&gt; View in &lt;a href="http://www.asp.net/learn/mvc/tutorial-37-vb.aspx"&gt;VB&lt;/a&gt; or &lt;a href="http://www.asp.net/learn/mvc/tutorial-37-cs.aspx"&gt;C#&lt;/a&gt;&lt;br /&gt;&lt;u&gt;&lt;font color="#0066cc"&gt;&lt;strong&gt;#20 | &lt;/strong&gt;Validating with a Service Layer &lt;/font&gt;&lt;/u&gt;View in &lt;a href="http://www.asp.net/learn/mvc/tutorial-38-vb.aspx"&gt;VB&lt;/a&gt; or &lt;a href="http://www.asp.net/learn/mvc/tutorial-38-cs.aspx"&gt;C#&lt;/a&gt;&lt;br /&gt;&lt;u&gt;&lt;font color="#0000ff"&gt;&lt;strong&gt;#21 | &lt;/strong&gt;Validation with the Data Annotation Validators&lt;/font&gt;&lt;/u&gt; View in &lt;a href="http://www.asp.net/learn/mvc/tutorial-39-vb.aspx"&gt;VB&lt;/a&gt; or &lt;a href="http://www.asp.net/learn/mvc/tutorial-39-cs.aspx"&gt;C#&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;#21 is the&amp;nbsp;newest of these tutorials.&amp;nbsp; You&amp;#39;ll find different approaches in each tutorial.&lt;/p&gt;
&lt;p&gt;#19 has an interesting comment:&lt;br /&gt;&amp;quot;DateReleased value is validated automatically. Because the DateReleased property does not accept NULL values, the DefaultModelBinder generates a validation error for this property automatically when it does not have a value. If you want to modify the error message for the DateReleased property then &lt;strong&gt;&lt;em&gt;&lt;span style="BACKGROUND-COLOR:#ffff00;"&gt;you need to create a custom model binder&lt;/span&gt;&lt;/em&gt;&lt;/strong&gt;.&amp;quot;&lt;/p&gt;
&lt;p&gt;You &lt;strong&gt;&lt;em&gt;may&lt;/em&gt;&lt;/strong&gt; find help here:&lt;br /&gt;&lt;a href="http://www.hanselman.com/blog/SplittingDateTimeUnitTestingASPNETMVCCustomModelBinders.aspx"&gt;http://www.hanselman.com/blog/SplittingDateTimeUnitTestingASPNETMVCCustomModelBinders.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;#18 talks about &amp;quot;&lt;b&gt;Prebinding Validation and Postbinding Validation&lt;/b&gt;&amp;quot;:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;quot;There are actually two types of validation error messages – those generated before the HTML form fields are bound to a class and those generated after the form fields are bound to the class.&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://odetocode.com/Blogs/scott/archive/2009/04/27/12788.aspx"&gt;http://odetocode.com/Blogs/scott/archive/2009/04/27/12788.aspx&lt;/a&gt;&lt;br /&gt;&amp;quot;6 Tips for ASP.NET MVC Model Binding&amp;quot;&lt;br /&gt;&lt;a href="http://odetocode.com/Blogs/scott/archive/2009/05/05/12801.aspx"&gt;http://odetocode.com/Blogs/scott/archive/2009/05/05/12801.aspx&lt;/a&gt;&lt;br /&gt;&amp;quot;Iterating on an ASP.NET MVC Model Binder&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/magazine/dd942838.aspx"&gt;http://msdn.microsoft.com/en-us/magazine/dd942838.aspx&lt;/a&gt;&lt;br /&gt;&amp;quot;Building Testable ASP.NET MVC Applications&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.lostechies.com/blogs/jimmy_bogard/archive/2009/03/17/a-better-model-binder.aspx"&gt;http://www.lostechies.com/blogs/jimmy_bogard/archive/2009/03/17/a-better-model-binder.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://stephenwalther.com/blog/archive/2009/02/25/asp.net-mvc-tip-49-use-the-linqbinarymodelbinder-in-your.aspx"&gt;http://stephenwalther.com/blog/archive/2009/02/25/asp.net-mvc-tip-49-use-the-linqbinarymodelbinder-in-your.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;For more links, use Google:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; asp.net mvc custom model binder&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Gerry (Lowry)&lt;/p&gt;
&lt;p&gt;P.S.:&lt;/p&gt;
&lt;p&gt;Interesting is:&amp;nbsp; &lt;a href="http://www.codeplex.com/FluentValidation"&gt;http://www.codeplex.com/FluentValidation&lt;/a&gt;&lt;br /&gt;and &lt;a href="http://fluentvalidation.codeplex.com/Wiki/View.aspx?title=mvc"&gt;http://fluentvalidation.codeplex.com/Wiki/View.aspx?title=mvc&lt;/a&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;quot;Integration with ASP.NET MVC&amp;quot;&lt;/p&gt;</description></item><item><title>Re: why must I change each int/money column in Models to Nullable: True ?</title><link>http://forums.asp.net/thread/3275129.aspx</link><pubDate>Sun, 05 Jul 2009 05:54:29 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3275129</guid><dc:creator>zielony</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3275129.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=3275129</wfw:commentRss><description>&lt;p&gt;&lt;a href="http://forums.asp.net/members/gerrylowry.aspx"&gt;gerrylowry&lt;/a&gt; the problem is that in visual studio 2010 beta1 + .net 4.0 + MVC 1.1 &lt;/p&gt;&lt;p&gt;I have in database table books with column price which can&amp;#39;t be null.&lt;/p&gt;&lt;p&gt;I can write:&lt;/p&gt;&lt;pre name="code" class="c-sharp"&gt;[AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Create([Bind(Exclude = &amp;quot;id_book&amp;quot;)] books book)
        {
            if (book.price == null)
            {
                ModelState.AddModelError(&amp;quot;price&amp;quot;, &amp;quot;You must write price.&amp;quot;);
            }
            if (!ModelState.IsValid) return View(book);

..................

}&lt;/pre&gt;&lt;p&gt;&lt;br /&gt; &lt;br /&gt;&lt;/p&gt;&lt;p&gt;But when user stays field with price empty he gets error: &amp;quot;A value is required.&amp;quot; (not mine error).&lt;/p&gt;&lt;p&gt;I must change in Model this table column &amp;quot;Nullable&amp;quot; from False on True. Then user gets mine error: &amp;quot;You must write price.&amp;quot;.&lt;/p&gt;&lt;p&gt;I understand why but now I must change this property for each column which is number and isn&amp;#39;t Primary Key or ForeignKey in Model. It isn&amp;#39;t comfortable :)&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: why must I change each int/money column in Models to Nullable: True ?</title><link>http://forums.asp.net/thread/3274950.aspx</link><pubDate>Sat, 04 Jul 2009 20:29:21 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3274950</guid><dc:creator>levib</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3274950.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=3274950</wfw:commentRss><description>&lt;p&gt;&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="/Themes/fan/images/icon-quote.gif"&gt; &lt;strong&gt;zielony:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;Why in ASP.NET MVC and linq to sql I must change each int/money column in Models on Nullable: True - otherwise if I in form stay this field empty I get error: &amp;quot;A value is required.&amp;quot; + mine communicate of error. &lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;/p&gt;&lt;p&gt;Empty form fields represent null values - they can&amp;#39;t be converted to any useful data type line int, decimal, etc.&amp;nbsp; If you try submitting a form with an empty field, the binder will try assigning null to that property.&amp;nbsp; And if the property is non-nullable, the setter will fail, and the binder will propagate the error back up to the user.&lt;/p&gt;&lt;p&gt;You have a few options for this.&amp;nbsp; If you really want the properties to be able to contain empty values, you can make them nullable and the framework will allow empty values to go through.&amp;nbsp; (It will still fail if you type something truly invalid, e.g. the phrase &amp;quot;dog&amp;quot; for a numeric property.)&amp;nbsp; If you don&amp;#39;t want the binder to handle these properties at all, don&amp;#39;t render form input elements for them.&amp;nbsp; It really depends on what you want to be able to store in your backend.&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: why must I change each int/money column in Models to Nullable: True ?</title><link>http://forums.asp.net/thread/3274930.aspx</link><pubDate>Sat, 04 Jul 2009 19:37:05 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3274930</guid><dc:creator>gerrylowry</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3274930.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=3274930</wfw:commentRss><description>&lt;p&gt;In ASP.NET MVC, a lot gets done automatically; sometimes too little, sometimes too much.&lt;/p&gt;
&lt;p&gt;In your Controller, there are various cheats you can use.&lt;/p&gt;
&lt;p&gt;Example:&amp;nbsp; assume that &lt;strong&gt;expiryDate&lt;/strong&gt; is a database column that can not be null.&lt;br /&gt;You do not want to force your end user to enter &lt;strong&gt;expiryDate&lt;/strong&gt;.&amp;nbsp; In your &lt;strong&gt;Controller&lt;/strong&gt;,&lt;br /&gt;you could check whether expiry date is null, something like:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; if (formData.expiryDate == null) formData.expiryDate = DateTime.Now + 30;&lt;/p&gt;
&lt;p&gt;As long as you do this kludge before you apply changes, you will be safe AFAIK&amp;nbsp;and you will not have to worry about having nulls in your physical database.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Gerry (Lowry)&lt;/p&gt;</description></item></channel></rss>