Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am a facing a situation in which i need to use a Date time picker inside a Gridview.

My Date time is working in Outside the grid. But when it comes to inside the Grid its not populating the Date time .



Regards,
Posted
Comments
[no name] 16-Nov-12 0:05am    
show your code..
Shashi226 16-Nov-12 0:20am    
<asp:TemplateField HeaderText="Exam Date">
<itemtemplate>
<asp:TextBox ID="txtexamdate" runat="server" ReadOnly="true" class = "Calender" />
<img alt="" src="calender.png" />




</script>
<script src="../../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.dynDateTime.min.js" type="text/javascript"></script>
<script src="../../Scripts/calendar-en.min.js" type="text/javascript"></script>
<link href="../../Styles/calendar-blue.css" rel="stylesheet" type="text/css" />
<link href="../../Styles/calendar-blue.css" rel="stylesheet" type="text/css" />
<script type = "text/javascript">
$(document).ready(function () {
$(".Calender").dynDateTime({
showsTime: true,
ifFormat: "%Y/%m/%d %H:%M",
daFormat: "%l;%M %p, %e %m, %Y",
align: "BR",
electric: false,
singleClick: false,
displayArea: ".siblings('.dtcDisplayArea')",
button: ".next()"
});
});
</script>

I think you are following the codes given in article DateTimePicker in ASP.Net GridView using jQuery DateTimePicker Plugin[^].
I downloaded the code and tested. It is working fine.

I can see one difference in your code.
The code should be like below...
XML
<asp:TemplateField HeaderText="Date Of Birth">
           <ItemTemplate>
               <asp:TextBox ID="txtDOB" runat="server" ReadOnly="true" class = "Calender" />
               <img src="calender.png" />
           </ItemTemplate>
       </asp:TemplateField>

whereas you don't have the ItemTemplate tags inside asp:TemplateField tags.
Place your textbox for calendar and calendar image inside the ItemTemplate.

And one more thing. Make sure you have all css and js files added to the project.
In case you don't have them at correct path, this will not work.
You can see these errors in the console panel of the firebug of Mozilla browser.

Thanks...
Happy coding...:)
 
Share this answer
 
Comments
Shashi226 16-Nov-12 3:29am    
Even i too tested that code but its not working when i placed the code content in my project.
What is the problem ?
Do you get any exceptions while running it ?
What are your developing environment softwars ?
Shashi226 16-Nov-12 3:40am    
Date time picker is not populating when im clicking the calender image.
no Exceptions, Vs-2008
Have you checked the console window of Firebug if there is any error or not ?
Shashi226 16-Nov-12 3:45am    
No i didnt do that

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