Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created grid in that I have implemented datepicker. After selecting date from datepicker of second/third cell it always reflect in first cell only.

Please help ..!

What I have tried:

This is jquery code:

JavaScript
$(function () {
    $("#<%= gvRequests.ClientID %>").find("input[id$='txtApprovalEndDate']").datepicker();
});
//Re-Create for on page postback
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(function () {
     $("#<%= gvRequests.ClientID %>").find("input[id$='txtApprovalEndDate']").datepicker();
});


This is grid view code :
XML
<asp:templatefield headertext="Approval End Date" insertvisible="False">
                           <itemtemplate>
                                <asp:textbox id="txtApprovalEndDate" clientidmode="Static" text="" dataformatstring="{dd/MM/yyyy}" cssclass="Datepicker" maxlength="10" runat="server">
Posted
Comments
Fernando_Costa 24-Jun-20 5:47am    
I not sure what you want, please be more clear

1 solution

You have ClientIDMode set to "static" so all textboxes will have the same id which is invalid, ids have to be unique. The browser is simply using the first one and ignoring the others. So remove the clientid mode

<asp:TextBox ID="txtApprovalEndDate" Text="" dataformatstring="{dd/MM/yyyy}" cssclass="Datepicker" maxlength="10" runat="server" />


Now update the js to find the element. Use the *= selector to find items that contain that text in their id

$("#<%= gvRequests.ClientID %>").find("input[id*='txtApprovalEndDate']").datepicker();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900