Add image into html table dynamically?

Try this: HtmlTable tbProductImage = new HtmlTable(); HtmlTableRow trImageRow = new HtmlTableRow(); for (int j = 0; j ID = "id"; imageProduct. ImageUrl = "url"; tdImageCell.Controls. Add(imageProduct); trImageRow.Cells.

Add(tdImageCell); } } tbProductImage.Rows. Add(trImageRow).

I tested my code and it works for me. If it gives an error for you, I believe the error must lie outside of the code block in your question. – Bazzz Jan 31 at 11:55 I know I wrote the same code another page it works but im trying to make works upside code... and I don't understand what the hell is happening.... – serim urhan Jan 31 at 12:43.

You should not use Controls. Add, use Rows. Add instead, try this: tbProductImage.Rows.

Add(trImageRow); But I'm not sure if this will solve your problem.

Thx but error is in line: tdImageRow.Controls. Add(imageProduct); Cannot get inner content of because the contents are not literal. I don't understand – serim urhan Jan 31 at 8:57 serim.

Change your question if you are having the error there. You wrote that you are having error at tbProductImage.Controls. Add(trImageRow); You cannot add a tablerow as control to a table.

If you seek help, be clear about your problem! – Pabuc Jan 31 at 9:58 there is not an error, code is clear, I know because the same code works clearly on another page... – serim urhan Jan 31 at 11:12.

Try this: tbProductImage.Rows. Add(trImageRow); tbProductImage is an HtmlTable. If you want to add an HtmlTableRow to the table, you need to add it to the Rows collection.

Adding it to the Controls collection will give you the error that you currently see. So changing your code from Controls to Rows should give you what you need. The same thing applies for adding a cell to a row.

A few lines above, you want to replace trImageRow.Controls. Add(tdImageRow); with trImageRow.Cells. Add(tdImageRow).

Thx but error is in line: tdImageRow.Controls. Add(imageProduct); Cannot get inner content of because the contents are not literal. I don't understand – serim urhan Jan 31 at 8:58 I added some more explanation, and a similar suggestion for fixing code above in the row where you are adding the cell to the row.

– Yaakov Ellis Jan 31 at 9:11 thx but ive already did it but my problem is not this , there is htmlcell innertext and innerhtml properties... my doesn't work because of them and I still don't know th reason – serim urhan Jan 31 at 9:38.

Add a cell to the row, and then add a control to the cell. We do this kind of thing... Dim r As TableRow Dim c As TableCell Dim lit As Literal Me.displayTable.Rows.Clear() r = AddRow(Me. DisplayTable, 0) c = AddCell(r, 100) lit = New Literal lit.

Text = "Thank you for registering your interest. " c.Controls. Add(lit) The Table, Row, and Cell objects are from the System.Web.UI.

WebControls namespace, but they render as HTML tables.

No it doesn't work... thx again... – serim urhan Jan 31 at 11:14.

You are trying to add the image to a tablerow (TR) this won't work because TRs can only contain tablecells (TD). You are trying to add the row to the table directly instead of to the table's Rows collection: The way to do it is: Make a new row. Make new cell.

Add image to new cell. Add new cell to new row. Add new row to table (via table's Rows connection) EDIT: Sorry, my eyesight isn't what it was - old age and late nights :-( I think your code goes off-road because you're not adding the row to the table's Rows collection: tbProductImage.Controls.

Add(trImageRow).

Look at the code again... :D – serim urhan Jan 31 at 11:14 My bad, pls see Edit above. – 5arx Jan 31 at 11:26.

TbProductImage is an HtmlTable. If you want to add an HtmlTableRow to the table, you need to add it to the Rows collection. Adding it to the Controls collection will give you the error that you currently see.

So changing your code from Controls to Rows should give you what you need. The same thing applies for adding a cell to a row. A few lines above, you want to replace trImageRow.Controls.

Add(tdImageRow); with trImageRow.Cells.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions