I need the difference of two datetime down to the millisecond comparison the first datetime is going to be less than the second, its to stop a loop in the gridviews delete event
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
if (!Ok2Delete(e.RowIndex)) return;
// your logic goes here and the above IF statement
// will hopefully guarantee your code to run once.
}
private bool Ok2Delete(int ri) // ri is the record index to be deleted
{
if (Session["ri"] == null ||
(!((ri == ((int)Session["ri"])) &&
(DateTime.Now.Subtract((DateTime)Session["ri_time_stamp"]).Seconds < 2))))
{
Session["ri"] = ri;
Session["ri_time_stamp"] = DateTime.Now;
return true;
}
return false;
}
this code isn't working as expected