0

I tried to bind a Jquery datapicker event to a child gridview. It works fine with the parent gridview. However I couldn't get it work for the child gridview. For the parent grid, this works fine:

 $('#<%=gvInvoiceClient.ClientID %>').find('input:text[id$="txtDOB').datepicker({...});

As the childgrid is rendered with different IDs that end with _gvChild, I used various wildcard selectors such as the following but couldn't get it work:

$('[id$=gvDetail]').find('input:text[id$="txtInvoiceEnd"]').datepicker({...});
$('[id*=gvChild]').find('input:text[id$="txtInvoiceEnd"]').datepicker({...});

here's the gridview

 <div runat="server" id="gvChild"> 
  <asp:GridView ID="gvDetail" runat="server">
     <Columns>                                          

     <asp:TemplateField HeaderText="Birthday" >
      <ItemTemplate>
   <asp:Label ID="lblPeriodStartDt" runat="server" </asp:Label>
  </ItemTemplate>                                                       
   <FooterTemplate>  <asp:TextBox ID="txtDOB" runat="server"></asp:TextBox>                                                        
   </FooterTemplate>
</asp:GridView>

2 Answers 2

1

I ended up using a class selector and it worked. $(".calendar").datepicker({'''});

  <asp:GridView ID="gvChild" runat="server">
     <Columns>                                       
   <FooterTemplate>  <asp:TextBox ID="txtDOB"  CssClass ="calendar" runat="server"></asp:TextBox>                                                        
   </FooterTemplate>
</asp:GridView>
Sign up to request clarification or add additional context in comments.

Comments

0

There is a slight typo in your selector. If you have an outer element with id ending in gvChild, containing a text field with id ending in txtInvoiceEnd, you want:

$("[id$='gvChild']").find("input:text[id$='txtInvoiceEnd']").datepicker();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.