悬赏分:100 浏览:531 次
datset里一张datatable表,如何使输出为
sony: k500 k700 ...
nokia: 2650 3100 ...
表结构为:
mid typeid phone_type id name
223 3 k500 3 sony
224 3 k700 3 sony
......
235 5 2650 5 nokia
236 5 3100 5 nokia
......
as.net 的
|
8个月前 flypiging : 当然是代表更多的型号呢... |
|
8个月前 flypiging : 楼上的没写完吧....而且跟新建没什么关系吧 |
|
8个月前 沙加 : dr = dtPhoto.NewRow(); dr[0] = 236; dr[1] = "3100"; dr[2] = "nokia"; dtPhoto.Rows.Add(dr); gv1.DataSource = dtPhoto; gv1.DataBind(); string currentType = string.Empty; System.Text.StringBuilder sb = new System.Text.StringBuilder(); for (int i = 0; i < dtPhoto.Rows.Count; i++) { DataRow drPhoto = dtPhoto.Rows[i]; if (!currentType.EndsWith(drPhoto[2].ToString(), StringComparison.InvariantCultureIgnoreCase)) { sb.Append("<br />"); currentType = drPhoto[2].ToString(); sb.Append(currentType + " : "); } sb.Append(string.Format(" <a href=\"phonedetails.aspx?id={0}\">{1}</a> ", drPhoto[0], drPhoto[1])); } ltOutput.Text = sb.ToString(); } } //居然被截段了~~ |
|
8个月前 简单飞扬- : 前几天朋友面试时候遇到了一个类似的问题: 跟你这个类似的表结构 要求的结果也差不多 他那个问题一个查询语句就搞定了 只是 他那道题目 是用mysql数据库 |