I have a book database where i have book information. I have a row where i store the name of the picture of the book i want to display on the page. For example cprog.jpeg
Now, i want to append that name to the src to display the picture. However, its just displaying the name itself. Im not quite sure how to do it.
+ " <img src=\"{0} \">" + row[8].ToString() + "</div>"
Here is the complete code..
foreach (DataTable table in dsgrid2.Tables)
{
foreach (DataRow row in table.Rows)
{
strBooksInCategory +=
"<div style=\"height:150px;\">"
+ " <img src=\"{0} \">" + row[8].ToString() + "</div>"
+ " <div style=\"height:110px;float:left;padding-left:10px;\">"
+ " <div style=\"height=auto;left-margin:10px;\">" + row[0] + "</div>"
+ " <div style=\"height=auto;left-margin:10px;\">" + row[1] + "</div>"
+ " <div style=\"height=auto;left-margin:10px;\">" + row[2] + "</div>"
+ " <div style=\"height=auto;left-margin:10px;\">" + row[3] + "</div>"
+ " <div style=\"height=auto;left-margin:10px;\">" + row[4] + "</div>"
+ " <div style=\"height=auto;left-margin:10px;\">" + row[5] + "</div>"
+ " </div>"
+ "</div>";
strBooksInCategory += "<div style=\"height:10px;width=100%;\"></div>";
I am assuming row[8] is your image name… try something like
You will have to put in the path to the image too, that will look like
However… the other answerer is correct, this is very messy & will only break your heart later. Databound controls are the way to go, read up on DataGrids and Repeaters… it will be worth your while!