How do I enable/disable the Delete button on the List window based on data being loaded via data binding? I attempted to access the data via the GridView1_DataBound event, but while I’m getting seeing the correct number of rows in GridView1.Rows, the content appears to be empty.
protected void GridView1_DataBound(object sender, EventArgs e)
{
foreach (GridViewRow row in GridView1.Rows)
{
//
// Don't display delete link for non-admin users. (This is working fine.)
//
((LinkButton)row.FindControl("DeleteLinkButton")).Visible = (DataAccess.GetUserInfo(true).UserType == DataAccess.UserType.Admin);
//
// TODO: Instead of just making the button visible, if it is visible, enable
// or disable based on the row's DATESTAMP column.
//
DateTime dateStamp = Convert.ToDateTime(row.Cells[11].Text); // NO DATA RETURNED??
}
}
Try
RowDataBoundevent instead. This occurs for each row so you don’t have to loop through grid rows. However you will have to check the Row Type before uses. For that you will get most of the data needed in theGridViewRowEventArgs. This MSDN link has sample code.