• 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>

  • 相关阅读:
    C#多线程之旅(1)——介绍和基本概念
    C#多线程之旅(3)——线程池
    C# 插入或删除word分页符
    JavaScript里的类和继承
    CSS学习笔记——定位position属性的学习
    从零开始搭建架构实施Android项目
    ES5新特性:理解 Array 中增强的 9 个 API
    JQuery datepicker 用法
    客户端验证的极品--jQuery.validator
    兼容iefirefoxchrome的cursor
  • 原文地址:https://www.cnblogs.com/flyrain/p/datalist.html
Copyright © 2020-2023  润新知