Hi there,
Take a look at
this link; I have come to trust the CompareTo method.
Moreover, consider removing/deleting undesired buttons instead of just making them invisible.
By the way, the line:
string apintdate=DataBinder.Eval(e.Row.DataItem, "appoinmentDate").ToString();
does not seem to play a part in that code. If it is used afterwards, then ignore this note.
Cheers!