I have implemented date time picker in ASP.net textbox, but when i use this in gridview or nested gridview it fails..
what I want is.. through this JQuery Function
$(function () {
$("#<%= txtDate.ClientID %>").datepicker();
});
show date time picker when click on nested grid view given sample..
<asp:GridView ID="GV_Proc" runat="server" AutoGenerateColumns="false" CssClass="Grid"
DataKeyNames="Procedure_Code" OnRowDataBound="GV_ProcOnRowDataBound"
onselectedindexchanged="gvProc_SelectedIndexChanged" Width="512px">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<img alt = "" style="cursor: pointer" src="../images/plus.png" />
<asp:Panel ID="pnldiagtype" runat="server" Style="display: none">
<asp:GridView ID="gvProctype" runat="server" AutoGenerateColumns="false" CssClass = "ChildGrid">
<Columns>
<asp:TemplateField HeaderText="Select" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="">
<ItemTemplate>
<asp:CheckBox ID="chk_Select" runat="server"/>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
<ItemStyle Width="8%" />
</asp:TemplateField>
<asp:BoundField ItemStyle-Width="20%" DataField="Procedure_Type_ID" HeaderText="Procedure Type Id" />
<asp:BoundField ItemStyle-Width="20%" DataField="Procedure_Code" HeaderText="Procedure Code" />
<asp:BoundField ItemStyle-Width="100%" DataField="Procedure_Type_Desc" HeaderText="Description" />
<asp:TemplateField HeaderText="Remarks" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="">
<ItemTemplate>
<asp:TextBox ID="txt_Remarks" CssClass=".text" runat="server"></asp:TextBox>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
<ItemStyle Width="8%" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Date" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="">
<ItemTemplate>
<asp:TextBox ID="txtDate" runat="server" />
<img src="../calender.png" />
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
<ItemStyle Width="8%" />
</asp:TemplateField>
</Columns>
</asp:GridView>
</asp:Panel>
</ItemTemplate>
<ItemStyle Width="8%" />
</asp:TemplateField>
<asp:BoundField ItemStyle-Width="150px" DataField="Procedure_Code" HeaderText="Procedure ID"/>
<asp:BoundField ItemStyle-Width="150px" DataField="Procedure_Description" HeaderText="Procedure Name" />
</Columns>
When I tried to build this, it shows
The name 'txtDate' does not exist in the current context
Any help will be appriciatable
when I used same function without grid view, run successfully..
I am using following script and style sheet
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/themes/base/jquery-ui.css" type="text/css" media="all" />
<link rel="stylesheet" href="http://static.jquery.com/ui/css/demo-docs-theme/ui.theme.css" type="text/css" media="all" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="//code.jquery.com/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="//code.jquery.com/jquery-1.8.0.js"></script>
<script type="text/javascript" src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
UPDATE:
<script type="text/javascript">
$(document).ready(function () {
$('.datepicker-text').datepicker();
});
and update textBox property as
<asp:TextBox ID="txtDate" runat="server" CssClass="datepicker-text"/>