日を現在の日付に追加したいと思います。たとえば、曜日を桁で入力し、現在の日付に追加したい日を選択します。asp.netを使用して現在の日付に日を追加する方法
がprotected void TextBoxPredictDays_TextChanged(object sender, EventArgs e)
{
string selectPredictDays = DropDownList1.SelectedItem.Value;
String Days1;
int Result;
Days1 = TextBoxPredictedClosing.ToString();
if (selectPredictDays == "Days")
{
Result = Convert.ToInt32(TextBoxPredictDays.Text) * 1;
TextBoxPredictedClosing.Text = Result.ToString();
}
else if (selectPredictDays == "Weeks")
{
Result = Convert.ToInt32(TextBoxPredictDays.Text) * 7;
TextBoxPredictedClosing.Text = Result.ToString();
}
else if (selectPredictDays == "Months")
{
Result = Convert.ToInt32(TextBoxPredictDays.Text) * 30;
TextBoxPredictedClosing.Text = Result.ToString();
}
}
plzのいずれかが私を助けることができる日、週、月を意味しますが、私は数日または数週間または月を選択したときに、それは日を示したが、現在の日付に それらを追加することはできませんここに私の設計コードは
です<asp:TextBox ID="TextBoxPredictDays" runat="server"
ontextchanged="TextBoxPredictDays_TextChanged" Width="101px" Height="14px" ></asp:TextBox>
<asp:DropDownList ID="DropDownList1" runat="server"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem>Days</asp:ListItem>
<asp:ListItem>Weeks</asp:ListItem>
<asp:ListItem>Months</asp:ListItem>
</asp:DropDownList>
あなたは=今日のDateTimeのためDateTime.Nowを求めています。 DateTime answer = today.AddDays(36); https://msdn.microsoft.com/en-us/library/system.datetime.adddays(v=vs.110).aspxを参照してください。 – Anil