protected void btnsub_Click(object sender, EventArgs e) { schedule ob= new schedule(); ob.u_id = Convert.ToInt32(txt_id.Text); bool isSubjectDuplicate = obj.schedule.Any(schedule => schedule.u_id == ob.u_id); if (isSubjectDuplicate == true) { Label2.Text = "YOU ALREADY SCHEDULED YOUR EXAM DATE"; } else { var res1 = DateTime.Today.ToString(); var res = (from test in obj.schedule where test.date == res1 select test).FirstOrDefault(); if (res != null) { ob.name = txt_name.Text; ob.date = txtdate.Text; obj.schedule.AddObject(ob); } else { Response.Redirect(""); } Response.Redirect("start.aspx"); obj.SaveChanges(); } }
DateTime
DateTime.Today.ToString()
var res =
ToString("MM/dd/yyyy")
res1
test.date
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)