62,046
社区成员
发帖
与我相关
我的任务
分享
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
var sr = from d in ds.Tables[0].AsEnumerable()
where d.Field<int>("com_id") == Convert.ToInt32(ds.Tables[0].Rows[i]["com_id"])
select d;
foreach (var item in sr)
{
if (item.Field<int>("type") == 5)
{
hong = "color:red;";
int a = item.Field<int>("com_id");
}
if (item.Field<int>("type") == 7)
{
hot = "11111111111111111111111";
int b = item.Field<int>("com_id");
}
if (item.Field<int>("type") == 8)
{
ji = "<img src='images/ji.gif'>";
int c = item.Field<int>("com_id");
}
}
ca = comacc.GetModel(Convert.ToInt32(ds.Tables[0].Rows[i]["com_id"]), " and Trade=" + com);
li.Add(Convert.ToInt32(ds.Tables[0].Rows[i]["com_id"]));
if (ca != null)
{
sb.AppendLine("<li><a href='firminfos.aspx?id=" + ca.Comid + "' target='_blank' title='" + ca.CompanyName + "'><span class='index_shopComTitle' style='cursor: hand;" + hong + " '>" + ca.CompanyName + hot + ji + "</span></a></li>");
}
}
var result = from r in dtt.AsEnumerable()
group r by r["Com_ID"] into m
select new {
type = m.Key,
com_ID = string.Join(",", m.Select(r => r["type"]).ToArray()) };
foreach (var dr in result)
{
Console.WriteLine("type:{0},com_ID:{1}", dr.type, dr.com_ID);
}
DataTable dtt = new DataTable();
dtt.Columns.Add("ID");
dtt.Columns.Add("Com_ID");
dtt.Columns.Add("Type");
dtt.Rows.Add(40, 8204, 5);
dtt.Rows.Add(60, 8206, 5);
dtt.Rows.Add(7, 8206, 7);
dtt.Rows.Add(34, 8207, 5);
dtt.Rows.Add(46, 8220, 5);
dtt.Rows.Add(51, 8222, 5);
dtt.Rows.Add(28, 8223, 5);
dtt.Rows.Add(22, 8225, 5);
dtt.Rows.Add(70, 8251, 5);
var result = (from r in dtt.AsEnumerable()
group r by r["Com_ID"] into m
select new { type = m.Key,
com_ID = string.Join(",", m.Select(r => r["type"]).ToArray())
}
).ToList();