Solved

cannot convert from 'System.Web.UI.HtmlControls.HtmlTableRow' to 'System.Web.UI.WebControls.TableRow'

Posted on 2003-10-31
1
2,850 Views
Last Modified: 2012-08-14
I am getting the following error when I try to add a row to a table

cannot convert from 'System.Web.UI.HtmlControls.HtmlTableRow' to 'System.Web.UI.WebControls.TableRow'

I am using the following code snippet to add a row to the table

HtmlTableRow objRow = new HtmlTableRow();
HtmlTableCell objCell = new HtmlTableCell();
objCell.InnerHtml += ds.Tables[0].Rows[0][0].ToString();
objRow.Cells.Add(objCell);

Table1.Rows.Add(objRow)

The element Table1 is there in the aspx file.

<asp:Table id="Table1"
style="Z-INDEX: 102; LEFT: 72px; POSITION: absolute; TOP: 56px"
runat="server"
Width="192px">
</asp:Table>

Any ideas would be appreciated.
0
Comment
Question by:rxraza
1 Comment
 
LVL 6

Accepted Solution

by:
zrh earned 20 total points
ID: 9661884
Well, a HtmlTableRow is for a HtmlControls.HtmlTable, a TableRow is for a WebControls.Table (two different beasts).  

This is a HtmlTable control:
<table runat="server" id="myHtmlTable">
     ...
</table>

This is a Table WebControl:
<asp:Table id="myTableWebControl" runat="server">
    ...
</asp:Table>

Try doing something like:
TableRow objRow = new TableRow();
TableCell objCell = new TableCell();
objCell.Text += ds.Tables[0].Rows[0][0].ToString();
objRow.Cells.Add(objCell);

Table1.Rows.Add(objRow)

Hope that helps,
ZRH
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now