Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to make Responsive DataList asp.net

I have an Asp.net DataList control in my page. It is currently having repeatcolumns set to 4 which will give me 4 columns in each row. But I want to make this responsive and set the value to 1 for smaller screen sizes. Below is my asp.net control:

<asp:DataList runat="server" RepeatDirection="Horizontal" RepeatColumns="4" ID="dd" class="vex-res">

How can I achieve this?

like image 736
newguy Avatar asked Dec 04 '22 06:12

newguy


2 Answers

You cannot make DataList to be responsive, because it renders as Table.

Instead, you need to use ListView with bootstrap (or some other responsive framework).

<asp:ListView ID="ListView1" runat="server" ...>
    ...
    <ItemTemplate>
        <div class="row">
            <div class="col-md-4"><%# Eval("Name") %></div>
            <div class="col-md-4"><%# Eval("Email") %></div>
            <div class="col-md-4"><%# Eval("Address") %></div>
        </div>
    </ItemTemplate>
</asp:ListView>
like image 169
Win Avatar answered Dec 28 '22 06:12

Win


This Work My Home :

<asp:DataList ID="dlCustomers" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow" CssClass="row">
    <ItemTemplate>
   <%-- <div class="row">--%>
    <div class="col-sm-4"><!--THUMBNAIL#2-->
    <div class="panel-body">
      <span class="label label-warning"><%# Eval("status")%></span>
      <div class="thumbnail label-success">
        <asp:Image ID="Image1" runat="server" ImageUrl='<%# "~/" +Eval("image1").ToString().Trim() %>' Width="150px" Height="150px" />
        <div class="caption"><h4>Rp.<small> <%# Eval("harga")%></small></h4>
          <strong><%# Eval("judul") %></strong>
          <p>
          <small>LT:<strong>  <%# Eval("luastanah")%> m2</strong> </small> <small> LB : <strong>  <%# Eval("luasbangunan")%> m2</strong> </small> 
          <small>Setifikat : <strong><%# Eval("sertifikasi")%></strong> </small> <br />
         <small> Kamar : <strong><%# Eval("kamartidur")%></strong> </small><br />
         <small> Kamar Mandi : <strong><%# Eval("kamarmandi")%></strong> </small>
          </p>
          <a href="#" class="btn btn-success">Lihat Details</a>
        </div>
      </div>
     </div>
     </div> 
      <%--</div>--%>
      </ItemTemplate>
</asp:DataList>

Responsive using bootstrap 3.3.6 ..

like image 43
Yohan Apriandi Avatar answered Dec 28 '22 06:12

Yohan Apriandi