How to dynamically add div in asp web page ?ie, if mssql server returned n rows from a query, i must place all these n rows in seperate div which has to be created dynamically.!!pls help (d case is when displaying search results in a web page like shopping sites)

<%@ Page Language="C#" %>
<!DOCTYPE html>
<script runat="server">
    protected void Button1_Click(object sender, EventArgs e)
    {
        TextBox text = new TextBox();
        text.Text = "This is the runtime textbox";
        text.Style["width"] = "300px";
        PlaceHolder1.Controls.Add(text);        

    }
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Button ID="Button1" runat="server" Text="Click to add TextBox" OnClick="Button1_Click" />
        <br />
        <br />
        <br/>
        <asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
    </div>
    </form>
</body>
</html>

you can use repeater control of asp.net for this purpose. just assign datasource to it.

Just use for Loop in your asp page :)

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.