在cs中Page_Load上面定义int i = 0;然后你循环里用不就行了

解决方案 »

  1.   

    add the code to the ItemDataBound event handler for the DataList:<td>
      <asp:Literal id=lit runat=server />
    </td>.......
    void Item_Bound(Object sender, DataListItemEventArgs e)
          {         if (e.Item.ItemType == ListItemType.Item || 
                 e.Item.ItemType == ListItemType.AlternatingItem)
             { Literal lit = (Literal)e.Item.FindControl("lit");
    string s = "";
    for(int i=1;i<=extCount;i++)
    {
      s += DataBinder.Eval(Container.DataItem, "Col"+i.ToString()).Tostring();
       } 
                 lit.Text = s;         }      }
      

  2.   

    panyee(快乐王子): 好像你那样不行,那样得到的只能是0,循环对他不起作用谢谢 saucer(思归, MS .NET MVP),我用你的方法试试,看看行不行