Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to have a datalist in asp with more than one column and I pass its data source from code behind and I've done it correctly and this is my code :

ASP.NET
 <asp:DataList runat="server" ID="dlCustom" RepeatColumns="4">
        <itemtemplate>
            <div class="col-md-12">
                <div class="pricing-head">
                  <h3><label><%# DataBinder.Eval(Container.DataItem,"CustomerName") %></label></h3></div>
  <div></div>
 <div><label><%# DataBinder.Eval(Container.DataItem, "CustomerDet") %></label</div>
</div>


but it is not responsive .I want that when I resize the webpage 2 or 3 columns change to one column and this wouldn't happen ! plz help me if I should use another component even.

What I have tried:

I don't know what should I use to get it responsive.
Posted
Updated 14-Nov-16 5:05am

1 solution

By default, the DataList[^] renders its items in a <table>, which breaks your responsive design.

You can change the RepeatLayout property to Flow, which removes the <table>, but it will then render line breaks between groups of items.

You'd probably have better luck using a ListView[^] instead.
ASP.NET
<asp;ListView ID="dlCustom" runat="server">
<layoutTemplate>
    <div class="row">
        <asp:placeholder ID="itemPlaceholder" runat="server"/>
    </div>
</layoutTemplate>
<itemTemplate>
    <div class="col-md-4 col-lg-3">
        <!-- 
        4 columns @ 1170px or wider; 
        3 columns @ 970px - 1169px; 
        1 column @ 969px or narrower 
        -->
        ...
    </div>
</itemTemplate>
</asp:ListView>
 
Share this answer
 

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