Click here to Skip to main content
14,389,715 members
Rate this:
Please Sign up or sign in to vote.
See more:
i have a two rad date picker in my leave apply form with IDs rdpdatefrom and rdpdateto.
i have also used one textbox for no. of days. in this,when user enter no of days and select date from in rdpdatefrom,rdpdateto automatically fill according to no. of days and date enter in rdpdatefrom.but problem is,when user select date from (rdpdatefrom) and the selected day of date is saturday and user enter 2 days in textbox then according to datefrom and no of days enter in textbox,dateto is set to an sunday,i want dateto is set to monday.so finally i want that if user apply leave and if saturday,sunday,monday comes in sequence,so the datefrom is skip sunday.
for example-if user apply leave for two days and datefrom day of date is saturday,so dateto appears on monday.
my code is shown below:

protected void rdpDateFrom_SelectedDateChanged(object sender, Telerik.WebControls.SelectedDateChangedEventArgs e)
  {
      if (txtnoOfday.Text == "")
      {
          lblDateMsg.Text = "Enter No. of Leave Days";
          lblDateMsg.Visible = true;

          rdpDateUpto.SelectedDate = null;
          rdpDateUpto.Enabled = false;
      }
      else
      {
          rdpDateUpto.Enabled = true;
          lblDateMsg.Visible = false;
          //rdpDateUpto.MinDate = Convert.ToDateTime(rdpDateFrom.SelectedDate);

        //  rdpDateUpto.MaxDate = rdpDateFrom.SelectedDate.Value.AddDays((Convert.ToInt16(txtnoOfday.Text)-1));
          rdpDateUpto.MinDate = rdpDateFrom.SelectedDate.Value.AddDays((Convert.ToInt16(txtnoOfday.Text) - 1));
         rdpDateUpto.MaxDate = rdpDateFrom.SelectedDate.Value.AddDays((Convert.ToInt16(txtnoOfday.Text) - 1));
          rdpDateUpto.SelectedDate = rdpDateFrom.SelectedDate.Value.AddDays((Convert.ToInt16(txtnoOfday.Text) - 1));
      }
  }



protected void txtnoOfday_TextChanged(object sender, EventArgs e)
  {

      if (rdpDateFrom.SelectedDate ==null)
      {
          rdpDateUpto.SelectedDate = null;
      }
      else if (txtnoOfday.Text =="")
      {
          rdpDateFrom.SelectedDate = null;
          rdpDateUpto.SelectedDate = null;
      }
      else
      {
          rdpDateUpto.Enabled = true;
          lblDateMsg.Visible = false;
         // rdpDateUpto.MaxDate = rdpDateFrom.SelectedDate.Value.AddDays((Convert.ToInt16(txtnoOfday.Text)-1));
          rdpDateUpto.MinDate = rdpDateFrom.SelectedDate.Value.AddDays((Convert.ToInt16(txtnoOfday.Text) - 1));
          rdpDateUpto.MaxDate = rdpDateFrom.SelectedDate.Value.AddDays((Convert.ToInt16(txtnoOfday.Text) - 1));
          rdpDateUpto.SelectedDate = rdpDateFrom.SelectedDate.Value.AddDays((Convert.ToInt16(txtnoOfday.Text) - 1));
      }
  }
Posted

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

You should check if
datefrom.DayOfWeek = DayOfWeek.Saturday

and then do, what is necessary to be done (calculate new dateto or something like this).
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100