简体   繁体   English

将值从一个文本框传递到ASP.Net Gridview中的另一个

[英]Passing value from one textbox to another in ASP.Net Gridview

I have two fields in the GridView 1. Notification Date 2. Effective Date 我在GridView中有两个字段。1.通知日期2.生效日期

When user entered/change date in the Notification date, I would like to add 10 addtional days in the Notification date value and auto populate in the effective date every time when user change the notification date. 当用户在通知日期中输入/更改日期时,我想在通知日期值中添加10个附加天,并在每次用户更改通知日期时自动在生效日期中填充。 Please advise: 请指教:

<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>

Are you married to using the AjaxControlToolkit? 您是否愿意使用AjaxControlToolkit? Have you considered jqueryui? 你考虑过jqueryui吗? If you set up the fields as a datepicker , you can listen to the change event of the 1st box and update the 2nd one accordingly. 如果将字段设置为日期选择器 ,则可以侦听第一个框的change事件并相应地更新第二个框。

Update The CalendarExtender probably works the same way as the datepicker. 更新 CalendarExtender的工作方式可能与datepicker相同。 If you want immediate updates to show, you'll need to use javascript. 如果要显示立即更新,则需要使用javascript。 You'll still need to listen on the change event. 您仍然需要聆听change事件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM