ASP.NET - Date and time, getting a parse error - does not contain extension or parse definition

Asked By sha lini on 04-Jun-13 02:09 AM

{

protected void Page_Load(object sender, EventArgs e)

{

if (!IsPostBack)

{

DateTime today = System.DateTime.Today;

DateTime yesterday = today.AddDays(-1);

DateTime tomorrow = today.AddDays(1);

DateTimeLoan.Items.Add(

String.Format("{0:dd MMM yyyy}",

today));

DateTimeLoan.Items.Add(

String.Format("{0:dd MMM yyyy}",

yesterday));

DateTimeLoan.Items.Add(

String.Format("{0:dd MMM yyyy}",

tomorrow));

}

}

protected void DateTimeLoan_SelectedIndexChanged(object sender,

EventArgs e)


{

Calendar1.TodaysDate =

DateTime.ParseExact(DateTimeLoan.SelectedItem.Text);

}

}

Danasegarane Arunachalam replied to sha lini on 05-Jun-13 01:46 AM
What is DateTimeLoan ?
Hemanth Kumar replied to sha lini on 10-Jun-13 02:25 AM
Shalini ,

 Is "DateTimeLoan" a Listbox ? I think you are adding DateTime Parsed items to the Listbox.
sha lini replied to Hemanth Kumar on 11-Jun-13 10:00 PM
yes, dropdownlist.