用DataList,将RepeatDirection设为Horizontal,RepeatColumns设为2。

解决方案 »

  1.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    <style>
    .td1{ border-top-width:0}
    .td2{ border-bottom-width:0}
    </style>
    </head><body>
    <table width="200" border="1" cellpadding="0" cellspacing="0
    ">
      <caption>
      aaa
      </caption>
      <tr >
        <th scope="row" class="td1">1</th>
        <td class="td1">2</td>
        <td class="td1">3</td>
      </tr>
        <tr>
        <th scope="row" class="td2">4</th>
        <td class="td2">5</td>
        <td class="td2">6</td>
      </tr>
      <tr>
        <th scope="row" class="td1">7</th>
        <td class="td1">8</td>
        <td class="td1">9</td>
      </tr></table>
    </body>
    </html>//用DataGrid时在ItemCreate事件中将 Item.Cells里的每个TabelCell的cssclass 普通项为td1,交替项为td2。
      

  2.   

    private void dg_ItemCreated(object sender, DataGridItemEventArgs e)
    {
    if(e.Item .ItemType ==ListItemType.Item)
    {
    foreach(TableCell tc in  e.Item.Cells )
    {
    tc.CssClass ="td2";
    }
    }
    if(e.Item .ItemType ==ListItemType.AlternatingItem )
    {
    foreach(TableCell tc in e.Item .Cells )
    {
    tc.CssClass ="td1";
    }
    }
    }
      

  3.   

    楼上方法我不太明白,如果我可以用datagrid那我直接用2楼的DataList的方法好了。