0

This void will set the value of the label text to the previous month. For example: If today's date is 4/20/2017 the will set the label to 3/20/2017

What I am want to do is set the label text to first day of the previous month like this: 3/1/2017 Just not quite sure how to do that.

protected void PMonth_Click(object sender, EventArgs e)
{

    //Loads the hidden
    if (ViewState["datacountnm"] == null)
    { ViewState["datacountnm"] = 0; }
    ViewState["datacountnm"] = ((int)ViewState["datacountnm"]) - 1;

    lblSelectedDate.Text = DateTime.Now.AddMonths((int)ViewState["datacountnm"]).ToShortDateString();           
}
DebPepDevuan
  • 469
  • 14
  • 30

0 Answers0