Adding date automatically to textbox when i select an item from drop down list

I have a drop down list which has 3 items in it, i also have two Textboxes, Textbox1 and Textbox2. I want that when I select item1 from Dropdownlist and enter a date in Textbox1, The date in Textbox2 should be changed to 3years ahead of the date in Textbox1. Similarly when i select Item2 in dropdownlist and enter a date in Textbox1 the date in textbox2 should be automatically changed to (Textbox1 date+5years). I have the date in MM/DD/YYY format. Any ideas how to achive it using C# code. I know that I can use a stored procedure for this but I want to accomplish this using C# code.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

skolantiAuthor Commented:
Hi, I am a beginner in ASP.Net web development, Can you provide me with sample code according to my Scenario?
aspx page:

 <asp:DropDownList ID="DropDownList1" runat="server"
        <asp:ListItem Value="3">3 years</asp:ListItem>
        <asp:ListItem Value="5">5 years</asp:ListItem>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>

aspx.cs page

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)

        if (TextBox1.Text != "")
            DateTime GivenDate = Convert.ToDateTime(TextBox1.Text);

            if (DropDownList1.SelectedValue == "3")
                TextBox2.Text = GivenDate.AddYears(3).ToString();
            if (DropDownList1.SelectedValue == "5")
                TextBox2.Text = GivenDate.AddYears(5).ToString();

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Introduction to Web Design

Develop a strong foundation and understanding of web design by learning HTML, CSS, and additional tools to help you develop your own website.

skolantiAuthor Commented:
Thanks, This code worked but I had to make some changes based on my program.
skolantiAuthor Commented:
Thanks, this code worked fine but I had to make some changes based on my Program logic.
B is a bit unfriendly, I gave you the entire code needed to do what you needed... but thanks anyway
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.