簡體   English   中英

將值從一個文本框傳遞到ASP.Net Gridview中的另一個

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

我在GridView中有兩個字段。1.通知日期2.生效日期

當用戶在通知日期中輸入/更改日期時,我想在通知日期值中添加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>

您是否願意使用AjaxControlToolkit? 你考慮過jqueryui嗎? 如果將字段設置為日期選擇器 ,則可以偵聽第一個框的change事件並相應地更新第二個框。

更新 CalendarExtender的工作方式可能與datepicker相同。 如果要顯示立即更新,則需要使用javascript。 您仍然需要聆聽change事件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM