如何在ASP.NET中使用seprately DataList控件来显示数据组? [英] How to display group data seprately using DataList in ASP.NET?

查看:222
本文介绍了如何在ASP.NET中使用seprately DataList控件来显示数据组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有以下数据的SQL表,

I have a sql table which have the following data,

Id   City      Country 
---  ------    ------------
1    Delhi     India
2    New York  United States
3    Karachi   Pakistan
4    Mumbai    India
5    Lahore    Pakistan
6    Kanpur    India
7    Delhi     India
8    Mumbai    India

现在,我想在我的web应用程序,显示上述数据显示如下;

Now, I want to display the above data in my web app as displayed below;

India
Delhi (2)    Mumbai (2)    Kanpur (1)    

United States
New York (1)

Pakistan
Karachi (1)    Lahore (1)

请告诉我:


  • 的SQL查询,因为我想这将获取数据。我想城市,国家和计数(所有城市分组)

  • 以及如何显示在我上面的ASP.NET C#提供的格式所取得的数据。有没有我们可以使用,我想显示的数据的控制。或者我们写任何定制code,如果定制code,那么请告诉我code这一点。

感谢

推荐答案

您SQL应



select country,city,count(city)
from dbo.location 
group by country,city order by country

然后使用datarepeter显示数据。按照此<一个href=\"http://www.eggheadcafe.com/tutorials/aspnet/d89d1d96-03f1-4784-bbb2-a3db1af393f5/aspnet-datalist-and-data.aspx\"相对=nofollow>链接

这篇关于如何在ASP.NET中使用seprately DataList控件来显示数据组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆