Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
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 15-Nov-12 18:04pm
Comments
Krunal R at 16-Nov-12 0:05am
   
show your code..
Shashidhar226 at 16-Nov-12 0:20am
   
<asp:TemplateField HeaderText="Exam Date">

<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>
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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...
<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...Smile | :)
Comments
Shashi226 at 16-Nov-12 3:29am
   
Even i too tested that code but its not working when i placed the code content in my project.
Tadit Dash at 16-Nov-12 3:37am
   
What is the problem ?
Do you get any exceptions while running it ?
What are your developing environment softwars ?
Shashi226 at 16-Nov-12 3:40am
   
Date time picker is not populating when im clicking the calender image.
no Exceptions, Vs-2008
Tadit Dash at 16-Nov-12 3:42am
   
Have you checked the console window of Firebug if there is any error or not ?
Shashi226 at 16-Nov-12 3:45am
   
No i didnt do that
Tadit Dash at 16-Nov-12 3:48am
   
Please check that.
Just click on that calendar image and then check the console of Firebug.
That will show you the errors.
Please check and let me know, what you have found ?

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



Advertise | Privacy | Mobile
Web03 | 2.8.140926.1 | Last Updated 16 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

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