zoukankan      html  css  js  c++  java
  • DataList实现绑定数据的横向排列[转]

    DataList及repeater都可以实现绑定数据的横向排列:      

    <table><tr><td>
           <asp:DataList ID="DataList1" runat="server" RepeatDirection="Horizontal" RepeatColumns="5">
            <ItemTemplate>                      
              <a href='show.aspx?ipath=file://202.114.32.172/Files/<%# DataBinder.Eval(Container.DataItem, "sid") %>' target="_blank">
                    <%# DataBinder.Eval(Container.DataItem, "sid") %>
                </a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
             </ItemTemplate>
            </asp:DataList>
           </td></tr></table>

     数据绑定:

            string sql = "";
            sql = "...";
            MySqlDataAdapter da = new MySqlDataAdapter(sql, conn);
            conn.Open();
            DataSet ds = new DataSet();
            da.Fill(ds);        
            DataList1.DataSource = ds.Tables[0].DefaultView

            DataList1.DataBind();//2008-10-07

    竖着显示的(默认的显示方式):

                <asp:DataList ID="MyList" RepeatColumns="1" runat="server" Width="582px" HorizontalAlign="Center" >

                    <ItemTemplate>
                        <table border="0" width="400" align=center>
                              <tr>
                                <td width="25%">
                                    <%# DataBinder.Eval(Container.DataItem, "IID") %>
                                </td>
                                <td width="35%">
                                    <a href='show.aspx?ipath=<%# DataBinder.Eval(Container.DataItem, "IPATH") %>'>
                                        <%# DataBinder.Eval(Container.DataItem, "INAME") %>
                                    </a>
                                </td>
                                <td width="40%" valign="middle" >
                                    <a href='show.aspx?ipath=<%# DataBinder.Eval(Container.DataItem, "IPATH") %>'>
                                        <img src='<%# DataBinder.Eval(Container.DataItem, "IPATH") %>' width="100" height="75"
                                            border="0">
                                    </a>
                                </td>
                            </tr>
                        </table>
                    </ItemTemplate>
                </asp:DataList>

  • 相关阅读:
    开发者看过来,哪个移动平台好赚钱?
    EGit下配置Github项目
    用户接口(UI)设计的 20 条原则
    要想工作效率高,我们到底需要多少睡眠?
    Android 读取<metadata>元素的数据
    Android实现推送方式解决方案
    余晟:做个懂产品的程序员
    Gson简要使用笔记
    编程从业五年的十四条经验,句句朴实
    程序员不是包身工
  • 原文地址:https://www.cnblogs.com/flyrain/p/datalist.html
Copyright © 2011-2022 走看看