c# - How do I add the days to a date? -


i know datetime , adddays() commands. need take date in txtdatetime.text textbox , have nights spent in txtnights.text. because have no idea how add 2 , display them in third texbox, here code...

public partial class request : system.web.ui.page {     protected void page_load(object sender, eventargs e)     {         txtdatetime.text = datetime.now.tostring("d");          if (!ispostback)         {             calendar1.visible = false;         }          txtdatetime.focus();      }     protected void textbox1_textchanged(object sender, eventargs e)     {      }     protected void imgcalendar_click(object sender, imageclickeventargs e)     {         if (calendar1.visible)         {             calendar1.visible = false;         }         else         {             calendar1.visible = true;         }         }     protected void calendar1_selectionchanged(object sender, eventargs e)     {         txtdatetime.text = calendar1.selecteddate.toshortdatestring();     }     protected void checkbox1_checkedchanged(object sender, eventargs e)     {      }     protected void btnsubmit_click(object sender, eventargs e)     {         lblthank.text = "thank request";          double dblnights = 0;  //validation         //validation of nights         try         {             dblnights = convert.todouble(txtnights.text);              if (double.tryparse(txtnights.text, out dblnights))             {              }             else             {                 string script = "alert(\"number of nights must between 1 , 14!\");";             scriptmanager.registerstartupscript(this, gettype(),                                   "servercontrolscript", script, true);                 txtnights.focus();             }         }//end try          catch         {             string script = "alert(\"number of nights must integer!\");";             scriptmanager.registerstartupscript(this, gettype(),                                   "servercontrolscript", script, true);               txtnights.focus();         }//end catch            //end nights validation    //validation of email/name fields         boolean blnerrors = false;          if (txtname.text == "")         {             string script = "alert(\"name field required!\");";             scriptmanager.registerstartupscript(this, gettype(),                                   "servercontrolscript", script, true);              txtname.focus();         }          if (txtemail.text == "")         {             string script = "alert(\"email field required!\");";             scriptmanager.registerstartupscript(this, gettype(),                                   "servercontrolscript", script, true);              txtemail.focus();         }      //end validation of email/name fields //end validation     //depparture date          datetime arrivaldate = calendar1.selecteddate;          datetime departuredate = arrivaldate.adddays(1);          string formatteddate = departuredate.tostring("dd/mm/yy");          formatteddate = txtdeparture.text;          }//end submit     protected void btnclear_click(object sender, eventargs e)     {         txtdatetime.text = "";         txtemail.text = "";         txtname.text = "";         txtnights.text = "";         txtspecial.text = "";          radking.checked = false;         radstandard.checked = false;         radsuite.checked = false;         radbusiness.checked = false;         raddouble.checked = false;     }     protected void txtdeparture_textchanged(object sender, eventargs e)     {          datetime arrivaldate = calendar1.selecteddate;          datetime departuredate = arrivaldate.adddays(1);          string formatteddate = departuredate.tostring("dd/mm/yy");          formatteddate = txtdeparture.text;       } } 

i need take date selected in txtdatetime.text have number of nights staying entered txtnights.text , have 2 added , displayed in third box called txtdeparture.text

how go doing datetime , adddays()?

i'm little confused, think you're looking for?

datetime startdate = datetime.parse(txtdatetime.text); int daystospend = int.parse(txtnights.text); datetime enddate = startdate.adddays(daystospend); 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -