Hi!I am passing the date variable to a string fomat,then I am using the session to store the date in this format yyyy-mm-dd but see the code below to help fixing that.I want to convert Date from string to date format.But I am getting this error:
System.DateTime' does not contain a definition for 'ParseToExact'
int newIndex = e.NewSelectedIndex;//Row that the user is selecting(!e is a parameter)
object EventID = GridView1.DataKeys[newIndex][0].ToString();
object stadiumID = GridView1.DataKeys[newIndex][1].ToString();
string Game = GridView1.Rows[newIndex].Cells[0].Text;
string Location = GridView1.Rows[newIndex].Cells[1].Text;
string Date = GridView1.Rows[newIndex].Cells[2].Text;
string Hour = GridView1.Rows[newIndex].Cells[3].Text;
string Stadium = GridView1.Rows[newIndex].Cells[4].Text;
Session["data"] = string.Format("Event:{0}<br/>Location:{1}<br/>Date:{2}<br/>Hour:{3}<br/>Stadium name:{4}<br/>", Game, Location, Date, Hour, Stadium);
Session["StadeID"] = stadiumID;
Session["EventID"] = EventID;
Session["Game"] = Game;
Session["Location"] = Location;
Session["Date"]= DateTime.ParseToExact(Date, "HH:mm:ss", null);
Session["Hour"] = Hour;
Session["Stadium"] = Stadium;