Control with Htmlcontrol or Htmlgenericcontrol inside Gridview

Asked

Viewed 49 times

0

I have an html tag inside a gridview:

 <asp:GridView ID="GridView1" runat="server" ...etc..etc
    <i class="fa fa-cloud-upload fa-lg cinza" runat="server" id="icon_Nuvem"></i>
...

When the gridview is being populated I have the event:

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
   if (e.Row.RowType == DataControlRowType.DataRow)
    {

I need to replace this icon_cloud that has the class cinza for laranja

Usually when I use for example an image:

 <asp:Image ID="img_Historico" 

I would do so:

 Image IM_Hist = (Image)e.Row.FindControl("img_Historico");

But in the case of a <i> ? And even more I need something like a .toggleClass change the gray to orange

I don’t even know how to start;

1 answer

1


I found out with my own question.

 HtmlGenericControl icon = (HtmlGenericControl)e.Row.FindControl("icon_Nuvem");

Then I do the check I want and add the style itself and do not call an existing class.

if (dr[14].ToString() == "")
{
     icon.Attributes.CssStyle.Add("color", "#808080"); //cinza
}
else
{
    icon.Attributes.CssStyle.Add("color", "#ff6a00"); //laranja
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.