Solved

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

Posted on 2003-10-31
1
3,173 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

821 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