我有一个带有日期字段的DetailsView,我想在用户编辑时使用CalendarExtender。
在将CalendarExtender应用于字段之前,我将其作为常规绑定字段,并且值正确更新。然后我将字段更改为模板字段并将CalendarExtender应用于它。日历弹出正确,文本框输入日期,但是当我单击编辑时,似乎没有输入任何值。
这是我的代码:
<asp:DetailsView ID="DetailsView2" runat="server" Height="50px" Width="330px"
DataSourceID="SqlDataSource2" CssClass="GridViewStyle" GridLines="None"
AutoGenerateRows="False" DataKeyNames="ID" >
<Fields>
<asp:BoundField DataField="EmployeeID" HeaderText="EmployeeID"
SortExpression="EmployeeID" />
<asp:BoundField DataField="FirstName" HeaderText="FirstName"
SortExpression="FirstName" />
<asp:BoundField DataField="LastName" HeaderText="LastName"
SortExpression="LastName" />
<asp:BoundField DataField="SupervisorID" HeaderText="SupervisorID"
SortExpression="SupervisorID" />
<asp:BoundField DataField="JobID" HeaderText="JobID" SortExpression="JobID" />
<asp:TemplateField HeaderText="HireDate">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("HireDate") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Eval("HireDate") %>'> </asp:TextBox>
<asp:CalendarExtender Format="MM/dd/yyyy" ID="CalendarExtender1" runat="server" TargetControlID="TextBox1" Enabled="True" />
</EditItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True"
ShowInsertButton="True" />
</Fields>
<RowStyle CssClass="RowStyle" />
<EmptyDataRowStyle CssClass="EmptyRowStyle" />
<PagerSettings Mode="NumericFirstLast" PageButtonCount="5" />
<PagerStyle CssClass="PagerStyle" />
<HeaderStyle CssClass="HeaderStyle" Font-Bold="True" ForeColor="White"/>
<EditRowStyle CssClass="EditRowStyle" />
<AlternatingRowStyle CssClass="AltRowStyle" />
<HeaderTemplate>
Employee Information
</HeaderTemplate>
</asp:DetailsView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:dbConnectionString %>"
DeleteCommand="DELETE FROM [Employees] WHERE [EmployeeID] = @EmployeeID"
InsertCommand="INSERT INTO [Employees] ([EmployeeID], [FirstName], [LastName], [Email], [SupervisorID], [HireDate], [JobID], [Status]) VALUES (@EmployeeID, @FirstName, @LastName, @Email, @SupervisorID, @HireDate, @JobID, @Status)"
ProviderName="<%$ ConnectionStrings:dbConnectionString.ProviderName %>"
SelectCommand="SELECT * FROM [Employees] Where [EmployeeID]=@EmployeeID"
UpdateCommand="UPDATE [Employees] SET [EmployeeID] = @EmployeeID, [FirstName] = @FirstName, [LastName] = @LastName, [Email] = @Email, [SupervisorID] = @SupervisorID, [HireDate] = @HireDate, [JobID] = @JobID, [Status] = @Status WHERE [ID] = @ID">
<SelectParameters>
<asp:QueryStringParameter Name="EmployeeID"
QueryStringField="EmployeeID" Type="Int32" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="ID" Type="Int64" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="EmployeeID" Type="String" />
<asp:Parameter Name="FirstName" Type="String" />
<asp:Parameter Name="LastName" Type="String" />
<asp:Parameter Name="Email" Type="String" />
<asp:Parameter Name="SupervisorID" Type="String" />
<asp:Parameter Name="HireDate" Type="DateTime" />
<asp:Parameter Name="JobID" Type="Double" />
<asp:Parameter Name="Status" Type="String" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="EmployeeID" Type="String" />
<asp:Parameter Name="FirstName" Type="String" />
<asp:Parameter Name="LastName" Type="String" />
<asp:Parameter Name="Email" Type="String" />
<asp:Parameter Name="SupervisorID" Type="String" />
<asp:Parameter Name="HireDate" Type="DateTime" />
<asp:Parameter Name="JobID" Type="Double" />
<asp:Parameter Name="Status" Type="String" />
<asp:Parameter Name="ID" Type="Int64" />
</UpdateParameters>
</asp:SqlDataSource>
知道我在这里缺少什么吗?