protected void Page_Load(object sender, EventArgs e) { List<string> powerIds = new List<string> { "2", "3" }; List<PmsAnalog> analogs=new List<PmsAnalog>(); PmsAnalog a = new PmsAnalog("1"); PmsAnalog b = new PmsAnalog("2"); PmsAnalog c = new PmsAnalog("3"); PmsAnalog d= new PmsAnalog("4"); analogs.Add(a); analogs.Add(b); analogs.Add(c); analogs.Add(d); ObservableCollection<PmsAnalog> analog = new ObservableCollection<PmsAnalog>((from p in analogs from ids in powerIds where p.DeviceId == ids select p).ToList()); GridView1.DataSource = analog; GridView1.DataBind(); }
效果: