troubleshooting Question

How to Add Class and Styles to HTML Table in Code Behind without 'System.Web.UI.HtmlControls.HtmlGenericControl' cannot be converted to 'System.Web.UI.HtmlControls.HtmlTableRow'.

Avatar of Starr Duskk
Starr DuskkFlag for United States of America asked on
2 Comments1 Solution10 ViewsLast Modified:
I want to programmatically add the class and/or styles to an html table in
I'm getting this error. I'm using Visual Studio 2015.

When I build, I get this error and the code behind doesn't recognize the element:
 'System.Web.UI.HtmlControls.HtmlGenericControl' cannot be converted to 'System.Web.UI.HtmlControls.HtmlTableRow'.

<table id="TableAvailableRepeater"  runat="server" class="display scrollTable" style="width: 100%; text-align: left !important; white-space: nowrap; overflow: auto;">
 <tbody id="dataContainerAvailable" clientidmode="Static" runat="server">
                                    <asp:Repeater ID="repAvailableRepeater" runat="server">
                                            <%# Eval("dcBuildRow").ToString()%>

Open in new window

I read there were problems with VS2012 that caused this problem when there is a tbody or thead, but this is VS2015 and I removed the tbody and the error still occurrec.

This is the type of codebehind I'm hoping to use.

            Dim addClass = "display scrollTable"
            TableAvailableRepeater.Attributes.Add("class", addClass)
            TableAvailableRepeater.Attributes.Add("style", "width: 100%; text-align: left !important; white-space: nowrap; overflow: auto;")

Open in new window

Any ideas how to get this to work without the error?

Alfredo Luis Torres Serrano
Senior Net Developer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 1 Answer and 2 Comments.
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>


Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 1 Answer and 2 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004