Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
hi...
I create one empty div and I fill it's data with my value's in the database...
my problem is that I don't know how to control them, what i need is that when they reached a certain point they go to the next line and show the rest of the result in following line.
here is my C# code:
C#
protected void Page_Load(object sender, EventArgs e)
{
    try
    {
        var q = dc.Productions.Select(c => new { c.ID, c.Image, c.Info, c.Name, c.PurchaseItems, c.Price , c.cat_ID });
        foreach (var item in q)
        {
            if (Convert.ToInt32(Request.QueryString.Get("cat_ID")) == Convert.ToInt32(da.getCatNameByName(DropDownList1.SelectedValue)));
            {
                HtmlGenericControl newControl = new HtmlGenericControl("div");
                newControl.ID = item.ID.ToString();

                newControl.InnerHtml = "<div class='col-md-4 product-left single-left'><div class='p-one simpleCart_shelfItem'><a href='EachSample.aspx?id=" + item.ID + "'><img src=../AdminCP/ProductImages/" + item.Image + " alt='' /><div class='mask mask1'><span>Quick View</span></div></a><h4>" + item.Name + "</h4><p><a class='item_add' href='#'> <span class=' item_price'>" + item.Price + "</span></a></p></div></div>";
                main.Controls.Add(newControl);
            }

        }
    }

And this is my asp.net code:
CSS
<div style=" background-color:white; width:100%" class="col-md-9 p-left">
           <div class="product-one">
           <div id="main"  runat="server" class="col-md-4 product-left single-left">

           </div>
           <div class="clearfix"> </div>
       </div>
       </div>

the C# codes generate the div's in the 'main' div.
Posted
Comments
njammy 30-Jul-15 8:40am    
Is there a reason you cannot use a .NET data bound control e.g. data list view or gridview or Details View to achieve this?
Member 11873237 31-Jul-15 12:44pm    
well the .net controls,such as gridview they don't look so good on the website...Maybe good for admin panel but not for the users or guests. Is there a .net control that I could design the inside my self?
jgakenhe 31-Jul-15 15:22pm    
Repeater.
aidin Tajadod 31-Jul-15 20:04pm    
I am not sure I understood your problem, but it seems you have css issue. take a look at existing controls like jquery UI. it gives you better understanding on how to achieve what you want. by the way, why are you injecting your html code in your backend?
Member 11873237 1-Aug-15 0:40am    
@aidin Tajadod I designed one single <div> and auto generate the rest of them with HTML code generator and fill their values from the database...
my problem is that when one div is generated the next one goes next line(under the first one), I want to see how to put the second and third div right next to the first one.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900