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>

posted on 2009-03-31 14:58  cqsar  阅读(4307)  评论(0编辑  收藏  举报