In my gridview
I have a date column and in edit mode, I place there a date picker. The date picker is in javascript which uses a getElementById()
to get/set the value on the textbox.
This is the code of my gridview
with the date picker if in edit mode:
<asp:TemplateField HeaderText="Effective Date" HeaderStyle-CssClass="allWidth160" ItemStyle-HorizontalAlign="Center" ControlStyle-CssClass="txtCommon allWidth80 txtCenter">
<ItemTemplate>
<asp:Label runat="server" ID="lblEffDate" Text='<%#DataBinder.Eval(Container.DataItem, "EFF_DATE").ToString()%>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ClientIDMode="Static" ID="EffDate" runat="server" Text='<%#Bind("EFF_DATE") %>' />
<img alt="Calendar" src="../Images/DateTimePickerImg/cal.gif" style="cursor: pointer;" onclick="javascript: NewCssCal('txtEffDate')" />
</EditItemTemplate>
</asp:TemplateField>
I included the javascript file in the HEAD:
<script src="../Library/DateTimePicker.js" type="text/javascript"></script>
When I click the image calendar it has an error somewhere in DateTimePicker.js file which leads to this code:
exDateTime = document.getElementById(pCtrl).value;
Where pCtrl
is txtEffDate.
Error: Object required
It seems that it cannot see the object txtEffDate
thats why it throws that error. I think that when it is in edit mode, it only show its drawing (the textbox appear) in the browser but its ID is still missing. Any thoughts? TIA