It seems the problem is when there's a null value in this field however,
which is completely expected. There are many date fields that could be null
before editing a record.
Why the following compile error occurs when I wrap the Bind("DateReceived")
statement in the FixNullDate function I just don't get.
Here's the HTML for the EditItemTemplate for the DateReceived field in the
DetailsView:
<EditItemTemplate>
<asp:Calendar ID="Calendar2" runat="server" SelectedDate='<%#
Bind("DateReceived") %>'
VisibleDate=' said:
</EditItemTemplate>
Here's the code for the FixNullDate function in the code behind page:
Function FixNullDate(ByVal dt As Object) As Date
If IsDBNull(dt) Then
Return Nothing
Else
Return dt
End If
End Function
This is the code in the business logic layer for updating a row:
Public Function UpdateAnnexation(ByVal annexationId As Integer, _
ByVal taxDistrictEntityId As Nullable(Of
Integer), _
ByVal dateReceived As Nullable(Of Date),
_
ByVal name As String, _
ByVal estimatedTaxImpacts As Nullable(Of
Decimal), _
ByVal estimatedAssessedValue As
Nullable(Of Decimal), _
ByVal acreage As Nullable(Of Single), _
ByVal gsReview As Nullable(Of DateTime),
_
ByVal legalOkay1 As Boolean, _
ByVal cityAnx As Nullable(Of DateTime),
_
ByVal statuteId As Nullable(Of Integer),
_
ByVal statuteRequirementsMet As Boolean,
_
ByVal ordinanceId As Nullable(Of
DateTime), _
ByVal legalOkay2 As Boolean, _
ByVal updateCities As Nullable(Of
DateTime), _
ByVal toLevySpecialist As Nullable(Of
DateTime), _
ByVal levySpecialistOkay As Boolean, _
ByVal updateCityAnx As Nullable(Of
DateTime), _
ByVal packetsSent As Nullable(Of
DateTime), _
ByVal ordinanceIn As Nullable(Of
DateTime), _
ByVal fromLevySpecialist As Nullable(Of
DateTime)) As Boolean
Adapter.UpdateAnnexation(taxDistrictEntityId, dateReceived, name,
estimatedTaxImpacts, _
acreage, estimatedAssessedValue, gsReview, legalOkay1, cityAnx,
statuteId, _
statuteRequirementsMet, ordinanceIn, legalOkay2, updateCities,
toLevySpecialist, _
levySpecialistOkay, fromLevySpecialist, updateCityAnx, packetsSent,
annexationId)
End Function
The code in the BLL for GetAnnexationByAnnexationID:
Public Function GetAnnexationByAnnexationId(ByVal annexationId As
Integer) As Annexationds.AnnexationsDataTable
Return Adapter.GetAnnexationByAnnexationId(annexationId)
End Function
And, here's the dataset queries:
To GetAnnexationByAnnexationID:
SELECT Acreage, AnnexationId, CityAnx, DateReceived,
EstimatedAssessedValue, EstimatedTaxImpacts, FromLevySpecialist, GSReview,
LegalOkay1, LegalOkay2, LevySpecialistOkay, Name, OrdinanceIn, PacketsSent,
StatuteId, StatuteRequirementsMet, TaxDistrictEntityId, ToLevySpecialist,
UpdateCities, UpdateCityAnx FROM Annexations WHERE (AnnexationId =
@AnnexationId)
And to UpdateAnnexation:
UPDATE Annexations
SET TaxDistrictEntityId = @TaxDistrictEntityId, DateReceived =
@DateReceived, Name = @Name, EstimatedTaxImpacts = @EstimatedTaxImpacts,
Acreage = @Acreage, EstimatedAssessedValue =
@EstimatedAssessedValue, GSReview = @GSReview, LegalOkay1 = @LegalOkay1,
CityAnx = @CityAnx, StatuteId = @StatuteId,
StatuteRequirementsMet = @StatuteRequirementsMet, OrdinanceIn =
@OrdinanceIn,
LegalOkay2 = @LegalOkay2, UpdateCities =
@UpdateCities, ToLevySpecialist = @ToLevySpecialist, LevySpecialistOkay =
@LevySpecialistOkay,
FromLevySpecialist = @FromLevySpecialist,
UpdateCityAnx = @UpdateCityAnx, PacketsSent = @PacketsSent
WHERE AnnexationId = @AnnexationId