Click here to Skip to main content
15,893,663 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi All,

I am getting a text box updated in gridview with date.

I am also using a general javascript date function for calender which is working fine on normal textboxes.

But I am unable to link the calendar to the textbox in grid. Following are the pieces of code used. pls advise.

XML
<asp:TemplateField HeaderText="Dispatch Dt" >

                 <ItemTemplate>
                    <asp:Label ID="lblDISPATCHDATE" runat="server" Text='<%# Eval("DispatchDate")%>' CssClass="grid_label" ></asp:Label>
                  </ItemTemplate>
                 <EditItemTemplate>
                        <script type="text/javascript" src="../../Scripts/textboxdate.js">  </script>
                     <asp:TextBox ID="txtDispatchDate" runat="server" Width="100" MaxLength="10" > </asp:TextBox>
                 </EditItemTemplate>
 </asp:TemplateField>



Java script function:
$(function () {
    $("input[id$='Date']").datepicker({ dateformat: "dd-mm-yy" });
    $("input[id$='Date']").datepicker("option", "dateFormat", "dd-mm-yy");
});
Posted
Comments
Sergey Alexandrovich Kryukov 7-Feb-15 9:25am    
What is that, "Java Script"? Java is not a scripting language, so there is no such thing. ;-)
—SA

1 solution

 
Share this answer
 
Comments
atul sharma 5126 15-Feb-15 12:00pm    
Thanks a lot Peter. It worked nicely.
One question though. I was not able to use ID$='Date' of common function and instead have to create separate function with id*=txtDispatchDate
Can u pls tell why?
Thanks again

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