Solved

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

Posted on 2003-10-31
1
2,971 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

896 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

13 Experts available now in Live!

Get 1:1 Help Now