2011-12-22 64 views
0

我在GridView 1.通知日期 2.有效日期从一个文本框传递值到另一个在ASP.Net的GridView

当用户输入在通知日期/改变日期,我想两个字段每当用户更改通知日期时,在通知日期值中添加10个附加天数,并在生效日期中自动填充。请告知:

<asp:DetailsView ID="DetailsView1" runat="server" 
DataKeyNames="ID" 
DataSourceID="ObjectDataSource1" 
OnDataBound="DetailsView_OnDataBound"> 
<Fields> 

<asp:TemplateField HeaderText="Notification Date"> 
<HeaderTemplate><span style="color:Red;">*</span> Notification Date </HeaderTemplate> 
<InsertItemTemplate> 
<asp:TextBox ID="txtNotificationDate" runat="server" Width="150" Text="" /> 
<cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtNotificationDate" PopupPosition="Right"/> 
</InsertItemTemplate> 
<EditItemTemplate> 
<asp:TextBox ID="txtNotificationDate" runat="server" Width="150" Text='<%# Eval("NotificationDate", "{0:d}") %>' /> 
<cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtNotificationDate" PopupPosition="Right"/> 
</EditItemTemplate> 
</asp:TemplateField> 

<asp:TemplateField HeaderText="Effective Date">  
<InsertItemTemplate> 
<asp:TextBox ID="txtEffectiveDate" runat="server" Width="150" Text="" /> 
<cc1:CalendarExtender ID="CalendarExtender2" runat="server" TargetControlID="txtEffectiveDate" PopupPosition="Right"/> 
</InsertItemTemplate> 
<EditItemTemplate> 
<asp:TextBox ID="txtEffectiveDate" runat="server" Width="150" Text='<%# Eval("EffectiveDate", "{0:d}") %>' /> 
<cc1:CalendarExtender ID="CalendarExtender2" runat="server" TargetControlID="txtEffectiveDate" PopupPosition="Right"/> 
</EditItemTemplate> 
</asp:TemplateField> 

</Fields> 
</asp:DetailsView> 

回答

0

您是否使用AjaxControlToolkit结婚?你有没有考虑jqueryui?如果将字段设置为datepicker,则可以收听第一个框的change事件并相应地更新第二个框。

更新 CalendarExtender可能与datepicker的工作方式相同。如果你想立即更新显示,你需要使用JavaScript。您仍然需要听取更改事件。

+0

我们是否有其他方式基于我上面发布的代码,否则我必须更改项目中的所有地方。请指教。 – Paul 2011-12-22 19:23:55

+0

我试图用OnClientDateSelectionchanged与CalendarExtender,但我不知道如何读取文本框的值,并更新第二个文本框。如果可以,请提供建议或举例。谢谢 – Paul 2011-12-22 20:16:02

+0

你有权访问jquery吗? – 2011-12-22 21:20:55

相关问题