Create HTML DIV Dynamically


This blog explains how we can generate a HTML Div dynamically. For this you must be aware of basic HTML, CSS.


Create a static string variable html:
public static string html = "";
Add <%=html%> in the aspx file inside of the from tag.

Add a function like this:
private string LoadDragEventsByUserID(string userId)
DataSet ds = Fetch dataset from your server
html = string.Empty;
for (int i = 0; i <= ds.Tables[0].Rows.Count – 1; i++)
html += "<div id=’" + ds.Tables[0].Rows[i]["Your Unique ID"].ToString() + "</div>";

return html;
return null;

Please note that your dataset rows will be contained different rows and columns, please change it according to your need. And also create css styles your own. If you need any help regarding style, feel free to ask me.