オブジェクトに問題があり、SqlDataSource
日付と時刻を SQL Server (2005) に保存しています。
データ ソース (適切に機能するビットを除外しました):
<asp:SqlDataSource ID="dataRequest" runat="server"
SelectCommand="request_select" SelectCommandType="StoredProcedure"
InsertCommand="request_insert" InsertCommandType="StoredProcedure"
UpdateCommand="request_update" UpdateCommandType="StoredProcedure"
>
<SelectParameters>
<!-- This section work fine -->
<asp:QueryStringParameter Name="requestid" Type="Int32" QueryStringField="requestid" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="requestid" Type="Int32" />
<!-- Lots of parameters here that work fine -->
<asp:Parameter Name="date_new_req" Type="DateTime" />
<asp:Parameter Name="date_new_acc" Type="DateTime" />
<asp:Parameter Name="date_quote_req" Type="DateTime" />
<asp:Parameter Name="date_quote_acc" Type="DateTime" />
<asp:Parameter Name="date_bh_approve_req" Type="DateTime" />
<asp:Parameter Name="date_bh_approve_acc" Type="DateTime" />
<asp:Parameter Name="date_work_req" Type="DateTime" />
<asp:Parameter Name="date_work_acc" Type="DateTime" />
<asp:Parameter Name="date_complete_req" Type="DateTime" />
<asp:Parameter Name="date_complete_acc" Type="DateTime" />
<asp:Parameter Name="date_declined_req" Type="DateTime" />
<asp:Parameter Name="date_declined_acc" Type="DateTime" />
<asp:Parameter Name="date_bh_declined_req" Type="DateTime" />
<asp:Parameter Name="date_bh_declined_acc" Type="DateTime" />
<asp:Parameter Name="date_archived_req" Type="DateTime" />
<asp:Parameter Name="requestor_ntlog" Type="String" />
</UpdateParameters>
<InsertParameters>
<!-- This section works fine -->
</InsertParameters>
</asp:SqlDataSource>
日付は単純にテキスト ボックスに表示され、その横に現在の日付と時刻をスタンプするための「スタンプ」ボタンが表示されます。各テキスト ボックスは にデータ バインドされておりSqlDataSource
、 内にありますFormView
。FormView
更新時に、テキスト フィールド、数値フィールド (テキスト ボックスと DDL の両方から)、およびチェック ボックスを含む の残りの情報が適切に送信されます。
<asp:FormView ID="requestProcessing" runat="server" DefaultMode="ReadOnly"
DataSourceID="dataRequest" DataKeyNames="requestid"
CssClass="editPanel" BorderStyle="None" EnableViewState="true">
<!-- There's loads of stuff within the FormView, but I've omitted it as it's irrelevant to this issue, but will post if necessary -->
<table class="dateTable" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="prompt">
<asp:Label ID="date_new_req_update_label" runat="server" Text="New job request" AssociatedControlID="date_new_req_update" /><br />
</td>
<td>
<asp:TextBox runat="server" ID="date_new_req_update" Text='<%# Bind("date_new_req") %>' CssClass="dataEntry" MaxLength="25" />
<a href="javascript:stampNow('requestProcessing_date_new_req_update')" class="dateButton">stamp</a>
</td>
<td>
<asp:TextBox runat="server" ID="date_new_acc_update" Text='<%# Bind("date_new_acc") %>' CssClass="dataEntry" MaxLength="25" />
<a href="javascript:stampNow('requestProcessing_date_new_acc_update')" class="dateButton">stamp</a>
</td>
</tr>
<tr id="row2" runat="server">
<td class="prompt">
<asp:Label runat="server" ID="date_quote_req_update_label" Text="Date of quote" AssociatedControlID="date_quote_req_update" />
</td>
<td>
<asp:TextBox runat="server" ID="date_quote_req_update" Text='<%# Bind("date_quote_req") %>' CssClass="dataEntry" MaxLength="25" />
<a href="javascript:stampNow('requestProcessing_date_quote_req_update')" class="dateButton">stamp</a>
</td>
<td>
<asp:TextBox runat="server" ID="date_quote_acc_update" Text='<%# Bind("date_quote_acc") %>' CssClass="dataEntry" MaxLength="25" />
<a href="javascript:stampNow('requestProcessing_date_quote_acc_update')" class="dateButton">stamp</a>
</td>
</tr>
<tr id="row3" runat="server">
<td class="prompt">
<asp:Label runat="server" ID="date_bh_approve_req_update_label" Text="Budget holder alerted" AssociatedControlID="date_bh_approve_req_update" />
</td>
<td>
<asp:TextBox runat="server" ID="date_bh_approve_req_update" Text='<%# Bind("date_bh_approve_req") %>' CssClass="dataEntry" MaxLength="25" />
<a href="javascript:stampNow('requestProcessing_date_bh_approve_req_update')" class="dateButton">stamp</a>
</td>
<td>
<asp:TextBox runat="server" ID="date_bh_approve_acc_update" Text='<%# Bind("date_bh_approve_acc") %>' CssClass="dataEntry" MaxLength="25" />
<a href="javascript:stampNow('requestProcessing_date_bh_approve_acc_update')" class="dateButton">stamp</a>
</td>
</tr>
<!-- I've omitted a lot of the dates here as they've all been tested and give the same result ... nothing! -->
</tbody>
</table>
</asp:FormView>
In the web.config
I've included a globalisation line specifically for the UK (just in case).
<globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="en-GB" uiCulture="en-GB"/>
The only code behind initiated by the update process sends a mail to a requestor:
Private Sub UpdateComplete(ByVal sender As Object, ByVal e As FormViewUpdatedEventArgs) Handles requestProcessing.ItemUpdated
If CType(requestProcessing.FindControl("mailUser"), CheckBox).Checked Then
Dim body As New StringBuilder()
With e.NewValues
'Notify the user of changes to the current request...
body.Append("<p>Changes have been made to your job request (")
body.Append(.Item("requestid").ToString())
body.Append(").</p>")
body.Append("<p>If you would like to review the changes to your job, please click ")
body.Append("<a href='")
body.Append(System.Web.HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority))
body.Append("/default.aspx?requestid=")
body.Append(.Item("requestid").ToString())
body.Append("&mode=select'>Click this link to view your job.</a>")
body.Append("<p>With kind regards,<br /><strong>The Minor New Works Team</strong></p>")
Functions.BuildEmail(CType(.Item("requestid"), Int32), True, False, "", _
"Changes have been made to your job request", body.ToString(), _
Functions.LocalMailFlagsEnum.BasicBody Or Functions.LocalMailFlagsEnum.VerboseSubject)
'Check to see if budget holder acceptance should be requested...
If Not .Item("date_bh_approve_req") Is Nothing AndAlso _
Not e.OldValues.Item("date_bh_approve_req") Is Nothing AndAlso _
.Item("date_bh_approve_req").ToString() <> "" AndAlso _
e.OldValues.Item("date_bh_approve_req").ToString() = "" Then
Functions.NotifyBudgetHolder(CType(.Item("requestid"), Int32))
End If
End With
End If
End Sub
I've tested each of the stored procedures necessary to both pull and push information and they work fine, producing the required results. Also, I've added a logging routine to capture the parameters passed to the stored procedure; on manual execution all parameters are logged to the log table, whereas on execution from the ASP.NET page the dates are excluded.
If anyone could shine any light on this issue or has experienced similar problems I'd love to hear about it.
-- EDIT -- This is ASP.NET 3.5