I have the following code is asp.net

<%@ Page Title="" Language="C#" MasterPageFile="~/Site02.Master" AutoEventWireup="true" CodeBehind="Tasks.aspx.cs" Inherits="DMS.Tasks" %>
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server">
        <div class="row-fluid sortable">
            <div class="box span5">
                    <div class="priority high"><span>Assigned By Me</span></div>

                <div class="task high" runat="server" id="Task01">
                        <div class="desc">
                            <div class="title">Test 45</div>
                            <div>ID: 1</div>
                            <div>Description: Test 45</div>
                            <div>Assigned To: Naheed Kassam</div>
                            <div>Status: Completed</div>
                            <div><asp:Button runat="server" ID="btn1" CssClass="btn btn-danger" Text="Open Task" /></div>
                        </div>
                        <div class="time">
                            <div class="date">Sep 30, 2014</div>
                            <div> 606 day(s)</div>
                        </div>
                </div>

            </div>

        </div>
    </telerik:RadAjaxPanel>
</asp:Content>

I would like to add divs synamically like the div for desc and time (And their contents) dynamically from a database.

Kindly am looking for advise and guidance on achieving this.

Regards,
Naheed

One method is to use a LIteral control on the page and build up your html as string in the code behind and then pass it to the literal.
<asp:Literal id="literal1" runat="server" />
In code:
string html = "<div class=''>....";
literal1.text = html;

another method - might be sligthly more versatile - could be to create a function in code behind and call the function from the aspx page via a code-block expression similar to this:

<div class="col1">
      <h3 class="spotit">
       <% GenerateTexts("h")%></h3>
                    <article>
                        <% GenerateTexts("p")%>
                    </article>
         </div>

In this example the function returns the proper html string via Response.Write(strPageText)

Hope it helped!

Tasos

Thanks guys, Using your responses and some research have been able to achieve what I wanted.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.