日期:2014-05-18  浏览次数:20405 次

DataList滚动显示
如何实现DataList滚动显示?麻烦高手帮忙解答

------解决方案--------------------
很简单 看看符合你的要求不
C# code
<%@ Page Language="C#" AutoEventWireup="True" %>
<%@ Import Namespace="System.Data" %>
 
<html>
   <script runat="server">
 
      ICollection CreateDataSource() 
      {
      
         // Create sample data for the DataList control.
         DataTable dt = new DataTable();
         DataRow dr;
 
         // Define the columns of the table.
         dt.Columns.Add(new DataColumn("IntegerValue", typeof(Int32)));
         dt.Columns.Add(new DataColumn("StringValue", typeof(String)));
         dt.Columns.Add(new DataColumn("CurrencyValue", typeof(double)));
         dt.Columns.Add(new DataColumn("ImageValue", typeof(String)));
 
         // Populate the table with sample values.
         for (int i = 0; i < 9; i++) 
         {
            dr = dt.NewRow();
 
            dr[0] = i;
            dr[1] = "Description for item " + i.ToString();
            dr[2] = 1.23 * (i + 1);
            dr[3] = "Image" + i.ToString() + ".jpg";
 
            dt.Rows.Add(dr);
         }
 
         DataView dv = new DataView(dt);
         return dv;
      }
 
 
      void Page_Load(Object sender, EventArgs e) 
      {

         // Load sample data only once, when the page is first loaded.
         if (!IsPostBack) 
         {
            ItemsList.DataSource = CreateDataSource();
            ItemsList.DataBind();
         }

      }
 
   </script>
 
<body>
 
   <form runat=server>

      <h3>DataList Example</h3>
 <MARQUEE DIRECTION="up" BEHAVIOR="SCROLL" SCROLLAMOUNT="10" SCROLLDELAY="200">
      <asp:DataList id="ItemsList"
           BorderColor="black"
           CellPadding="5"
           CellSpacing="5"
           RepeatDirection="Vertical"
           RepeatLayout="Table"
           RepeatColumns="3"
           ShowBorder="True"
           runat="server">

         <HeaderStyle BackColor="#aaaadd">
         </HeaderStyle>

         <AlternatingItemStyle BackColor="Gainsboro">
         </AlternatingItemStyle>

         <HeaderTemplate>

            List of items

         </HeaderTemplate>
               
         <ItemTemplate>

            Description: <br>
            <%# DataBinder.Eval(Container.DataItem, "StringValue") %>

            <br>

            Price: <%# DataBinder.Eval(Container.DataItem, "CurrencyValue", "{0:c}") %>

            <br>

            <asp:Image id="ProductImage"
                 ImageUrl='<%# DataBinder.Eval(Container.DataItem, "ImageValue") %>'
                 runat="server"/>

         </ItemTemplate>
 
      </asp:DataList>
   </MARQUEE>
   </form>
 
</body>
</html>

------解决方案--------------------
直接用msdn的例子帮你改了下 
 就是把datalist放到marquee元素里
------解决方案--------------------
楼主的问题事实上很简单,也不用什么js等,html中的一条语句搞定:
<marquee behavior="scroll" direction="up" height="300" width="500">
<asp:DataList ID="DataList1" runat="server" ......
<ItemTemplate>
......................
</ItemTemplate>
</asp:DataList>
</marquee>
------解决方案--------------------
简单说就是把DataList嵌套在marquee中,把marquee设置好。
8、15楼已经贴上了。
------解决方案--------------------