Reputation: 63
The below code is in Web Form aspx.cs file and needs to be displayed in front end. So how to loop inside div tags?
foreach (DataRowView row in dv)
{
Response.Write(row["Content"].ToString());
Response.Write("  ");
Response.Write(row["Page"].ToString());
Response.Write("<br/>");
}
Upvotes: 0
Views: 1709
Reputation: 8466
I was going to say something similar to NateBarbettini, but his answer is simpler. So you should do this:
In your .aspx file have your div declared like this:
<div id="div1" runat="server"></div>
And in your .cs code behind, in your Page_Load event, do this:
StringBuilder sb = new StringBuilder();
foreach (DataRowView row in dv)
sb.Append(row["Content"].ToString() + "  " + row["Page"].ToString() + "<br/>");
div1.InnerHtml = sb.ToString();
Upvotes: 1