using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Configuration;
using System.Data;
using System.Data.SqlClient;
public partial class autocomplete : System.Web.UI.Page
{
    const string conString = WebConfigurationManager.ConnectionStrings["dpCompanyConnectionString"].ConnectionString;
    public class ProductName
    {
        public string photoName { get; set; }
        public string photoNumber { get; set; }
        public List<ProductName> GetProduct(string key)
        {
            List<ProductName> results = new List<ProductName>();
            SqlConnection con = new SqlConnection(conString);
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = con;
            cmd.CommandText = "select top 12 * from(select cname,Number,DELYES from pricelist where cname LIKE  '%" + key + "%' union select cname,Number,DELYES from pricelist where Number LIKE  '%" + key + "%')t order by len(Number),DELYES";
            cmd.Parameters.AddWithValue("@keyword", key);
            using (con)
            {
                con.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    ProductName search = new ProductName();
                    search.photoName = (string)reader["cname"];
                    search.photoNumber = (string)reader["Number"];
                    results.Add(search);
                }
                return results;
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        
        //string keyword = Request.Form["q"];
        string keyword ="cd";        ProductName c = new ProductName();
        c.GetProduct(keyword);
        foreach (ProductName i in c)
        {
            Response.Write(i.photoName + "|" + i.photoNumber + "<br/>");
        }    }
}
如何才能让foreach可用?