Solved

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

Posted on 2003-10-31
1
3,459 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

729 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