Hi @Donald Symmons,
You put div inside itemtemplate so you need to use <div> belonging to HtmlGenericControl via e.Row property FindControl.
HtmlGenericControl blocked = (HtmlGenericControl)e.Row.FindControl("blocked");
HtmlGenericControl active = (HtmlGenericControl)e.Row.FindControl("active");
FULL CODE
protected void OnRowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
e.Row.Cells[3].Visible = false;
}
if (e.Row.RowType == DataControlRowType.DataRow)
{
for (int i = 1; i < e.Row.Cells.Count; i++)
{
e.Row.Cells[i].Attributes["onclick"] = Page.ClientScript.GetPostBackClientHyperlink(UsersGrid, "Select$" + e.Row.RowIndex);
e.Row.Cells[i].Style.Add("cursor", "pointer");
e.Row.Cells[i].ToolTip = "View Details.";
e.Row.Cells[3].Visible = false;
string Suspend = e.Row.Cells[4].Text;
HtmlGenericControl blocked = (HtmlGenericControl)e.Row.FindControl("blocked");
HtmlGenericControl active = (HtmlGenericControl)e.Row.FindControl("active");
if (Suspend == "1")
{
blocked.Visible = true;
active.Visible = false;
}
else
{
blocked.Visible = false;
active.Visible = true;
}
}
}
}
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.