indradeo says:
protected
void
GridView1_RowDataBound(
object
sender, GridViewRowEventArgs e)
{
if
(e.Row.RowType == DataControlRowType.DataRow)
{
string
empId = (e.Row.FindControl(
"hfEmployeeId"
)
as
HiddenField).Value;
if
(empId.Trim().ToLower() == Convert.ToString(Session[
"EmployeeID"
]).Trim().ToLower())
{
(e.Row.FindControl(
"btn_Edit"
)
as
Button).Visible =
true
;
}
else
{
(e.Row.FindControl(
"btn_Edit"
)
as
Button).Visible =
false
;
}
}
if
(e.Row.RowType == DataControlRowType.DataRow)
{
string
empId = (e.Row.FindControl(
"hfEmployeeId"
)
as
HiddenField).Value;
if
(empId.Trim().ToLower() == Convert.ToString(Session[
"EmployeeID"
]).Trim().ToLower())
{
(e.Row.FindControl(
"btn_Closed"
)
as
Button).Visible =
true
;
}
else
{
(e.Row.FindControl(
"btn_Closed"
)
as
Button).Visible =
false
;
}
}
}
Replace above with below code.
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow && (e.Row.RowState & DataControlRowState.Edit) != DataControlRowState.Edit)
{
string empId = (e.Row.FindControl("hfEmployeeId") as HiddenField).Value;
if (empId.Trim().ToLower() == Convert.ToString(Session["EmployeeID"]).Trim().ToLower())
{
(e.Row.FindControl("btn_Closed") as Button).Visible = true;
(e.Row.FindControl("btn_Edit") as Button).Visible = true;
}
else
{
(e.Row.FindControl("btn_Closed") as Button).Visible = false;
(e.Row.FindControl("btn_Edit") as Button).Visible = false;
}
}
}