asp.netgridviewcalendarpopupeditmodel

Popup Calendar in edit mode of asp.net gridview


All respected, I have a Master detail project asp.net (sql data) project in which Master.aspx along with code behind page Master.aspx.cs. Following is the code:

<asp:TemplateField HeaderText="Date of Failure" SortExpression="Failure_date" >
<EditItemTemplate>
<asp:TextBox ID="EditFailure_date" runat="server"  Text='<%# Bind("Failure_date", "{0:d}") %>' ></asp:TextBox><img src="_images/images.jpg" style="margin-top:3px;width:30px;height:30px;cursor:hand;" onclick="PopupPicker('EditFailure_date')" />  
<asp:RequiredFieldValidator ID="Failure_dateRequiredFieldValidator" runat="server" ControlToValidate="EditFailure_date" Display="Dynamic"  ErrorMessage="Can not be blank" SetFocusOnError="True"></asp:RequiredFieldValidator>
</EditItemTemplate>
<ItemStyle HorizontalAlign="Left" VerticalAlign="Top" />
<HeaderStyle HorizontalAlign="Left" VerticalAlign="Top" />
<ItemTemplate>
<asp:Label ID="Failure_date" runat="server"  Text='<%# Bind("Failure_date", "{0:dd/MM/yyyy}") %>'  ></asp:Label>
</ItemTemplate>
</asp:TemplateField>

Now I want to add a popup calender for above text box 'EditFailure_date' without codebehind. Please help.


Solution

  • You can use the AjaxControlToolkit's calendar like this:

    <asp:TextBox ID="EditFailure_date" runat="server"  Text='<%# Bind("Failure_date", "{0:d}") %>' ></asp:TextBox>
    <ajaxToolkit:CalendarExtender runat="server" ID="cal_EditFailure_date" TargetControlID="EditFailure_date" /> 
    

    Edit: You can also use a jquery solution such as the jQueryUI DatePicker