Last post Dec 16, 2008 12:34 PM by ricka6
Dec 16, 2008 09:00 AM|michaelr524|LINK
Dec 16, 2008 09:10 AM|vinkas|LINK
no in this case it will be add
what error its return when u add.
Dec 16, 2008 09:11 AM|davidtivy|LINK
Yes you need to validate all your textboxes etc, unless you have told the database to accept "NULL's". The insert will not product an error then.
Its a security feature as well as looking better.
This link explains how to validate your page.
Dec 16, 2008 09:38 AM|michaelr524|LINK
Dec 16, 2008 09:53 AM|davidtivy|LINK
Modify your table and check the Allow Nulls box for the field you wish not to validate.
The ID which should be the first field in the table should NOT allows NULL's always.
If you go to 'Column Properties' which is at the bottom of SQL Server 2005. You can set a 'Default Value or Binding'. For example if you type in getdate(), it will automatically insert todays date.
You could also default it to 1 or 0. Good if you are using checkboxes. You would need to make it a TinyInt if using checkboxes.
Any other questions?
Dec 16, 2008 10:00 AM|michaelr524|LINK
Dec 16, 2008 10:07 AM|davidtivy|LINK
The best way is to modify the tables. I strongly recommend doing it that way.
It would be sloppy programming any other way if you dont use validation and less secure.
Dec 16, 2008 11:06 AM|michaelr524|LINK
Dec 16, 2008 11:12 AM|davidtivy|LINK
If you just want to validate a textbox why dont you just use for example,
Dec 16, 2008 11:48 AM|michaelr524|LINK
Dec 16, 2008 11:57 AM|davidtivy|LINK
My final suggestion. If this doesnt help. Try reposting this again so its brand new. People will respond faster to brand new posts.
Dec 16, 2008 12:34 PM|ricka6|LINK
It would be a mistake to change the schema to allow nulls - you don't want to do that. For some fields you want the DB to supply the value (via defaults from the DB). What you really want is allow NULL at the client (ASP.Net side) but not allow nulls on
the server (the server will supply the value).
The easiest way to do this is with scaffoldColumn(false) to hide those columns. The problem with that approach is you never see the hidden fields - even on List and details pages where you are just reading them. You can use Steve's approach to hide the fields
on insert. Look for hiding columns at