Click here to Skip to main content
14,579,188 members
Rate this:
Please Sign up or sign in to vote.
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:

$(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 :
<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

Rate this:
Please Sign up or sign in to vote.

Solution 1

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();
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100