Convert your
ButtonField
to
TemplateField
column so you can have a control over the controls within it:
<asp:templatefield>
The at
RowDataBound
event, you could toggle the
Enabled
property of the
Button
based on your requirement. A quick example would be:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowState != DataControlRowState.Edit){
if (e.Row.RowType == DataControlRowType.DataRow){
string signoutDateString = e.Row.Cells[0].Text;
if(string.IsNullOrEmpty(signoutDateString)){
LinkButton lb = (LinkButton)e.Row.Cells[4].FindControl("lnkSignOut");
if (lb != null){
lb.Enabled = false;
}
}
}
}
}