ASP.NET Calendar - add 4 years.

I have a page that is used to add records to a Database. I have 2 Calendars - one for the purchase date and one for the retirement date of the equipment, which is 4 years from the purchase date by default, but can be manually changed if required.
So, I have the page and the two calendars, but I can't figure out how to get Calendar2 to Display a date 4 years in the future. Even 4 years from "DateTime.Today" would be fine!
<%@ Import Namespace="System.Data.Oledb" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

Protected Sub Page_Load()
 If Page.IsPostBack = False Then
  Label1.Visible = False
 End If
End Sub

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim Connection As New OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0;" & _
        "Data Source=E:\Company\New_Intranet\Guestbook2\App_Data\twit.mdb")
    Connection.Open()
        Dim Command As New OleDbCommand("INSERT INTO requests(Username, Forename, Make, Model, Serial, Acquired, Expires, Condition, Location, Comments" & _
    ")VALUES(@Username,@forename,@Make,@model,@Serial,@Acquired,@expires,@condition,@Comments,@location)", Connection)
        Command.Parameters.Add(New OleDbParameter("@Username", TextBox1.Text))
        Command.Parameters.Add(New OleDbParameter("@Forename", TextBox8.Text))
        Command.Parameters.Add(New OleDbParameter("@make", TextBox2.Text))
        Command.Parameters.Add(New OleDbParameter("@model", TextBox3.Text))
        Command.Parameters.Add(New OleDbParameter("@serial", TextBox4.Text))
        Command.Parameters.Add(New OleDbParameter("@acquired", Calendar1.SelectedDate))
        Command.Parameters.Add(New OleDbParameter("@expires", Calendar2.SelectedDate))
        Command.Parameters.Add(New OleDbParameter("@condition", DropDownList1.Text))
        Command.Parameters.Add(New OleDbParameter("@location", DropDownList2.Text))
        Command.Parameters.Add(New OleDbParameter("@comments", TextBox7.Text))
    Command.ExecuteNonQuery()

    Connection.Close()
        Label1.Text = "The Selected Record has been inserted."
    Label1.Visible = True

    'Clear the text boxes after a new insert
    TextBox1.Text = ""
        TextBox2.Text = ""
        TextBox3.Text = ""
        TextBox4.Text = ""
        TextBox7.Text = ""
        TextBox8.Text = ""
    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id=Head1 runat="server"><link rel="shortcut icon" href="images/headers/favicon.ico">
<title>Form to Add New Hardware</title>
<link href="Styles/Site.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .style1
        {
            color: #FF0000;
        }
        .style2
        {
            width: 275px;
        }
    </style>
</head>
<body>

<form id="form1" runat="server">
<table border="0" cellpadding="3" width="800"><tr><td align="center"><b>Surname</b> 
    <span class=style1>*</span></TD><TD align="center"><asp:TextBox ID="TextBox1" runat="server" Text=""></asp:TextBox></td>
<td><asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="TextBox1" runat="server" ErrorMessage="Please enter a Surname. Enter UNKNOWN if no User assigned"></asp:RequiredFieldValidator></td></tr>
<tr><td align="center"><b>Forename</b>     <span class=style1>*</span></TD><TD align="center"><asp:TextBox ID="TextBox8" runat="server" Text=""></asp:TextBox></td>
<td><asp:RequiredFieldValidator ID="RequiredFieldValidator7" ControlToValidate="TextBox8" runat="server" ErrorMessage="Please enter a Forename. Enter UNKNOWN if no User assigned"></asp:RequiredFieldValidator></td></tr>

<TR><td align="center"><b>Location</b> <span class="style1">*</span></td><td align="center">
<asp:DropDownList ID="DropDownList2" runat="server">
    <asp:ListItem Selected="True">Bolton (1st)</asp:ListItem>
    <asp:ListItem>Bolton (2nd)</asp:ListItem>
</asp:DropDownList></td></TR>


<tr><td align="center" class="style2"><B>Manufacturer</B> <span class="style1">*</span></TD><TD align="center"> <asp:TextBox ID="TextBox2" runat="server" Text=""></asp:TextBox></td>
<td><asp:RequiredFieldValidator ID="RequiredFieldValidator2" ControlToValidate="TextBox2" runat="server" ErrorMessage="Please enter a Manufacturer. Enter UNKNOWN if no Manufacturer available."></asp:RequiredFieldValidator></td></tr>
<TR><td align="center"><B>Model</B> <span class="style1">*</span></td><td align="center"> <asp:TextBox ID="TextBox3" runat="server" Text=""></asp:TextBox>
</td>
<td><asp:RequiredFieldValidator ID="RequiredFieldValidator3" ControlToValidate="TextBox3" runat="server" ErrorMessage="Please enter a Model. Enter UNKNOWN if no Model Number available."></asp:RequiredFieldValidator></td></TR>
<TR><TD align="center"><b>Serial Number</b> <span class="style1">*</span></TD><td align="center"><asp:TextBox ID="TextBox4" runat="server" Text=""></asp:TextBox>
</td>
<td><asp:RequiredFieldValidator ID="RequiredFieldValidator4" ControlToValidate="TextBox4" runat="server" ErrorMessage="Please enter a Serial Number. Enter UNKNOWN if no Serial Number available."></asp:RequiredFieldValidator></td></TR>
<TR><TD align="center"><b>Acquired Date (d/m/yy)</b> <span class="style1">*</span></TD><td align="center">

    <asp:Calendar ID="Calendar1" runat="server" BackColor="White" 
        BorderColor="#3366CC" BorderWidth="1px" CellPadding="1" 
        DayNameFormat="Shortest" Font-Names="Verdana" Font-Size="8pt" 
        ForeColor="#003399" Height="150px" Width="150px" SelectedDate="<%# DateTime.Today %>">
        <DayHeaderStyle BackColor="#99CCCC" ForeColor="#336666" Height="1px" />
        <NextPrevStyle Font-Size="8pt" ForeColor="#CCCCFF" />
        <OtherMonthDayStyle ForeColor="#999999" />
        <SelectedDayStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
        <SelectorStyle BackColor="#99CCCC" ForeColor="#336666" />
        <TitleStyle BackColor="#003399" BorderColor="#3366CC" BorderWidth="1px" 
            Font-Bold="True" Font-Size="10pt" ForeColor="#CCCCFF" Height="25px" />
        <TodayDayStyle BackColor="#99CCCC" ForeColor="White" />
        <WeekendDayStyle BackColor="#CCCCFF" />
    </asp:Calendar>



</td>

<TR><TD align="center"><b>Retirement Date (d/m/yy)</b> <span class="style1">*</span></TD><td align="center"> 

    <asp:Calendar ID="Calendar2" runat="server" BackColor="White" 
        BorderColor="#3366CC" BorderWidth="1px" CellPadding="1" 
        DayNameFormat="Shortest" Font-Names="Verdana" Font-Size="8pt" 
        ForeColor="#003399" Height="150px" Width="150px">
        <DayHeaderStyle BackColor="#FF6666" ForeColor="Maroon" Height="1px" />
        <NextPrevStyle Font-Size="8pt" ForeColor="#CCCCFF" BackColor="#FF5050" />
        <OtherMonthDayStyle ForeColor="#999999" />
        <SelectedDayStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
        <SelectorStyle BackColor="#99CCCC" ForeColor="#336666" />
        <TitleStyle BackColor="#FF5050" BorderColor="#3366CC" BorderWidth="1px" 
            Font-Bold="True" Font-Size="10pt" ForeColor="#CCCCFF" Height="25px" />
        <TodayDayStyle BackColor="#99CCCC" ForeColor="White" />
        <WeekendDayStyle BackColor="#CCCCFF" />
    </asp:Calendar>


</td>

<TR><td align="center"><b>Condition</b> <span class="style1">*</span></td><td align="center">
<asp:DropDownList ID="DropDownList1" runat="server">
    <asp:ListItem Selected="True">New/Near New</asp:ListItem>
    <asp:ListItem>Good</asp:ListItem>
</asp:DropDownList></td></TR>
<TR><td align="center"><b>Comments</b></td><td align="center"> <asp:TextBox ID="TextBox7" runat="server" Text=""></asp:TextBox></td></TR>
</table>

<asp:Button ID=Button1 runat="server" Text="Insert Record" OnClick="Button1_Click" />

<br />

<asp:Label ID=Label1 runat="server" Text=""></asp:Label>

</form>

</div>
</body>
</html>

Open in new window

The code above has been modified to only include the bits I think are required for this question. If more code is needed, I can supply it.
This kind of question has probably been asked before, but I can't seem to find it. Sorry!
winstallaAsked:
Who is Participating?
 
BuggyCoderConnect With a Mentor Commented:
Protected Sub Page_Load()
 If Page.IsPostBack = False Then
  Label1.Visible = False
Calender1.SelectedDate=DateTime.Today.AddYears(4)
Calender1.VisibleDate=DateTime.Today.AddYears(4)
 End If
End Sub

Open in new window

0
 
BuggyCoderCommented:
Calender1.SelectedDate=DateTime.Today.AddYears(4);
0
 
YZlatCommented:
I don't think

Calender1.SelectedDate=DateTime.Today.AddYears(4);

on its own will work. Try

Calender1.SelectedDate=DateTime.Today.AddYears(4)
Calender1.VisibleDate=DateTime.Today.AddYears(4)

Open in new window

0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
winstallaAuthor Commented:
Sorry for the daft question, but put the line(s) where, exactly?

Apologies - I'm still fudging(?) my way around ASP.NET. Trying to sprint before I can walk, I think...
0
 
Rose BabuSenior Team ManagerCommented:
set visible date with the selected date value.

selected date will only sets the date. but the visible date value will be displayed in browser
Calendar1.SelectedDate = Date.Today

Calendar2.VisibleDate = CDate(Date.Today.AddDays(4))
Calendar2.SelectedDate = CDate(Date.Today.AddDays(4))

Open in new window

Test this
0
 
Rose BabuSenior Team ManagerCommented:
i delayed to submit. ;-) @BuggyCoder has fixed the issue.
0
 
winstallaAuthor Commented:
This is working. Thank you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.