More preferably you can keep the all logic regarding this in the Gridview RowDataBound event. You can do something like-
protected void MyGrid_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
ImageButton btn = (ImageButton )e.Row.FindControl("ImageButton1");
btn.Visible= bool.Parse(DataBinder.Eval(e.Row.DataItem, "Flag").ToString());
}
}
For showing message when there is no data use
EmptyDataTemplate
<emptydatatemplate>
No data found!
</emptydatatemplate>
Please let me know if you still have any queries.
Hope, it helps :)