Last post Jan 19, 2011 10:26 PM by decker dong - msft
Jan 06, 2011 05:22 PM|Madog|LINK
I have a Listview with a LinqDataSource.
I am allocating a resoure called Bladder Scanners to clinicians on the day selected. The field in the database, 'Allocated_Bladder_Scanner_Id',
The 'nullable' property of the field in the dbml is set to allow nulls.
In the edit template, I have an unbound dropdownlist (drpBladderScannerDropdown) with an 'empty string' item added to cater for nulls, and
In order to show only bladder scanners which have not yet been allocated on the selected day, I am databinding the dropdownlist to a dictionary of unallocated bladder scanners in the
ItemDataBound event. I then add the currently selected bladder scanner as a listitem and set it as the selected item.
So far, so good, all works well.
However, if the clinician has a bladder scanner currently allocated, and then the user elects to not allocate the clinician a bladder scanner on that day by selecting 'Nothing' from the dropdownlist, the LinqDataSource fails to update the
field. It does not throw an exception, it just doesn't set the field to nulls.
In ItemUpdating I have the following code:
Dim drpBladderScannerDropdown As DropDownList = CType(ListView1.Items(e.ItemIndex).FindControl("drpBladderScannerDropdown"), DropDownList)
If drpBladderScannerDropdown.SelectedValue = String.Empty Then
e.NewValues("Allocated_Bladder_Scanner_Id") = CType(Nothing, Nullable(Of Byte))
e.NewValues("Allocated_Bladder_Scanner_Id") = drpBladderScannerDropdown.SelectedValue
Resource_Allocated = True
Jan 19, 2011 10:26 PM|Decker Dong - MSFT|LINK
e.NewValues("Allocated_Bladder_Scanner_Id") = Nothing
e.NewValues("Allocated_Bladder_Scanner_Id") = DbNull.Value