VS2008里面webform里多了System.Web.UI.WebControls.ListViewItem
以前2005里。只有winform里才有的吧,
不过2008里System.Web.UI.WebControls.ListViewItem的用法怎么不行了呢,比如说。foreach (ListViewItem lvi in this.ListView2.Items)
       {
            MyData[lvi.Index, 0] = lvi.Text;
            MyData[lvi.Index, 1] = lvi.SubItems[1].Text;
            MyData[lvi.Index, 2] = lvi.SubItems[2].Text;
            MyData[lvi.Index, 3] = lvi.SubItems[3].Text;
       }
以上代码在2005winform里运行是没问题的。但在2008webform里。lvi没有Index这个了。是不是有什么东西代替或别的什么方法呢,诚心向各位大侠求教。

解决方案 »

  1.   

     // Retrieve the current item.
        ListViewItem item = e.Item;    // Verify if the item is a data item.
        if (item.ItemType == ListViewItemType.DataItem)
        {
          // Get the EmailAddressLabel Label control in the item.
          Label EmailAddressLabel = (Label)item.FindControl("EmailAddressLabel");      // Display the e-mail address in italics.
          EmailAddressLabel.Font.Italic = true;
        }这个跟Winform的用法不一样