how to display 2 div tag in same line

Posted by Klbaiju under ASP.NET on 5/22/2013 | Points: 10 | Views : 1240 | Status : [Member] | Replies : 1
Hi All,
I want to display some records from database in div tag.
following is code

string divStr = "";

while (dtrAuthors.Read())
{
divStr += "<div id='disp'>";
divStr += "<ul>";
divStr += "<li><a href='#'><img src='pictures/" + dtrAuthors["image"].ToString() + "' height=75;width=100;float:left;/></a></li>";
divStr += "<li>"+dtrAuthors["productname"].ToString()+" |</li>";
divStr += "<li>" + dtrAuthors["unitprice"].ToString() + " </li>";
divStr += "</ul>";
divStr += "</div>";

}
Label1.Text = divStr;
style sheet
<style type="text/css">

li{display:inline;vertical-align:top; margin:5px;}

</style>
this is working fine.as contents inside div tag display in one line.
my requirement is every div tag will display in same line. how it is possible.

Regards
BAIJU





Responses

Posted by: Peermohamedmydeen on: 5/27/2013 [Member] Bronze | Points: 25

Up
0
Down
Put a table and place the div inside the td of the table

divStr += "<table><tr>";

while (dtrAuthors.Read())
{
divStr += "<td";
divStr += "<div id='disp'>";
divStr += "<ul>";
divStr += "<li><a href='#'><img src='pictures/" + dtrAuthors["image"].ToString() + "' height=75;width=100;float:left;/></a></li>";
divStr += "<li>"+dtrAuthors["productname"].ToString()+" |</li>";
divStr += "<li>" + dtrAuthors["unitprice"].ToString() + " </li>";
divStr += "</ul>";
divStr += "</div>";
divStr += "</td";

}

divStr += "</tr></table>";
Label1.Text = divStr;


Klbaiju, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response