Last post Jun 05, 2008 01:26 PM by Luca Morelli
Jun 05, 2008 01:26 PM|Luca Morelli|LINK
i have a problem editing linq to sql obejcts using a selectlist.
i have an object with some numeric nullable integer fields that are foreign keys with other objects: the fields are nullable, so if there is not value in the key i user the null value.
the edit the record in the form i use a select filling it with the list of object from the related table(Customers): if i use the list in the ViewData i obtain a select if the first item already selected and with no opportunity to leave the value of the
To solve this problem i would like to add to the list an item with null code and the text, but it is not possibile because the key field of the related table is not nullable, so i have to add a new element with code 0, for example, but when i process the
post of the form using BindingHelperExtensions.UpdateFrom
in the linq to sql object i find 0 in the unselected fields, but i have to change the manually in null to work fine in linq to sql, and i haven't found any way to add a simple row to a SelectList, giving code and text, but just a list of objects, so
i have to add this object to the list so the select is shown correctly?
i hope the description of the problem is clear: there is some way so that after the call of the UpdateFrom the fields are set to null if the select had no record selected ? changing manually from a fixed value to null may generate errors.