DATALIST可以把数据显示成N*N样式。但是我想显示成塔式样式。怎么写比如有30个数据,绑定后,显示如下      **
     ****
    ******
   ********每行增加两个。能否实现,或者其他办法也可以。谢谢了

解决方案 »

  1.   

    如果有规律的增加 你可以用asp的方式来做了
    datalist 等是不能做到的
      

  2.   

    用自定义控件修改Render是可以实现的。
      

  3.   

    using System;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.ComponentModel;namespace newscontrol
    {
    /// <summary>
    /// WebCustomControl1 的摘要说明。
    /// </summary>
    [DefaultProperty("Text"),
    ToolboxData("<{0}:WebCustomControl1 runat=server></{0}:WebCustomControl1>")]
    public class WebCustomControl1 : System.Web.UI.WebControls.WebControl
    {
    private string text; [Bindable(true),
    Category("Appearance"),
    DefaultValue("")]
    public string Text
    {
    get
    {
    return text;
    } set
    {
    text = value;
    }
    } /// <summary>
    /// 将此控件呈现给指定的输出参数。
    /// </summary>
    /// <param name="output"> 要写出到的 HTML 编写器 </param>
    protected override void Render(HtmlTextWriter output)
    {
    String s ="<table border='1' cellpadding='0' cellspacing='0' style='border-collapse: collapse' bordercolor='#FFCC66'";
                            s=s+" width='180' id='AutoNumber5'>";
                            s=s+" <tr><td width='100%' bgcolor='#CC6600'>";
    s=s+" <img src='04/home01.gif' width='12' height='14'><a href='http://finance.sina.com.cn'><font color='#FFFFFF'>技术动态</font></a></td>";
    s=s+" </tr>";
    s=s+" <tr><td width='100%'>";
    s=s+" <span class='F7'> ● </span><a href='http://finance.sina.com.cn/g/20040527/0712780434.shtml' target='_blank' style='color: #00007f'>";
    s=s+" 银监会将对电石铁合金业</a><br>";
    s=s+" <span class='F7'>● </span><a href='http://finance.sina.com.cn/t/20040527/0711780433.shtml' target='_blank' style='color: #00007f'>";
    s=s+" 中小企业板今日启动</a> <a href='http://finance.sina.com.cn/e/20040527/0708780431.shtml' target='_blank' style='color: #00007f'>";
    s=s+" 五只</a><br>";
    s=s+"   <span class='F7'>● </span><a href='http://finance.sina.com.cn/g/20040527/0801780536.shtml' target='_blank' style='color: #00007f'>";
    s=s+" 三级调查组进驻湖南嘉禾</a><br>";
    s=s+" <span class='F7'>● </span><a href='http://finance.sina.com.cn/roll/20040527/0636780294.shtml' target='_blank'";
    s=s+" style='color: #00007f'>新退市板块开局遭腰斩</a> <a href='http://finance.sina.com.cn/roll/20040527/0612780180.shtml' target='_blank'";
    s=s+" style='color: #00007f'>股</a><br>";
    s=s+" <span class='F7'>● </span><a href='http://tech.sina.com.cn/i/w/2004-05-27/0828367735.shtml' target='_blank' style='color: #00007f'>";
    s=s+" 纳斯达克计划扩大中国业</a><br>";
    s=s+" <span class='F7'>● </span><a href='http://tech.sina.com.cn/it/2004-05-26/1039367327.shtml' target='_blank' style='color: #00007f'>";
    s=s+" 微软柯达涉嫌垄断</a> <a href='http://tech.sina.com.cn/it/2004-05-27/1053367892.shtml' target='_blank' style='color: #00007f'>";
    s=s+" 盖茨将</a><br>";
    s=s+" <span class='F7'>● </span><a href='http://tech.sina.com.cn/it/t/2004-05-27/0854367758.shtml' target='_blank'";
    s=s+" style='color: #00007f'>广东电信条例提交审议 </a>";
    s=s+" <br>";
    s=s+" <span class='F7'>● </span><a href='http://tech.sina.com.cn/focus/top_100co/index.shtml' target='_blank' style='color: #00007f'>";
    s=s+" 电子信息百强揭晓 海尔联</a><br>";
    s=s+" <span class='F7'>● </span><a href='http://tech.sina.com.cn/ology/' target='_blank' style='color: #00007f'>";
    s=s+"  “长城”照片新说:不</a>";
    s=s+" </td></tr>";
    s=s+" <tr>";
    s=s+" <td width='100%'>";
    s=s+" <p align='right'>";
    s=s+"   <a style='color: #00007f' href='http://finance.sina.com.cn'>more&gt;&gt;&gt;&nbsp;&nbsp;";
    s=s+" </a>";
    s=s+" </td>";
    s=s+" </tr>";
    s=s+" </table>";
    output.Write(s);
    }
    }
    }
    只是个例子,需要按你输出格式修改