数据库代码
select top 10 name,(select count(*) from peopleall
where charindex(Area.name,duty)>0
) as strCount from dbo.Area
where 1=1 and layer='4' group by [name] having (select count(*) from peopleall where charindex(Area.name,duty)>0)<10
项目方法
protected void chax_Click(object sender, EventArgs e)
{
//获取页面文本框中的数据
string distinction = Request.Form["distinction"];
string strlayer = "";
if (distinction == "县级")
{
strlayer = "4";
}
if (distinction == "市级")
{
strlayer = "3";
}
if (distinction == "省级")
{
strlayer = "2";
} string tiaojian = Request.Form["tiaojian"];
int txtpeople = 0;
if (Request.Form["txtpeople"] != null)
{
txtpeople = Convert.ToInt32(Request.Form["txtpeople"].ToString());
}
wherestr += " and layer='" + strlayer + "'"+" group by [name] having (select count(*) from peopleall where charindex(Area.name,duty)>0)" + tiaojian + txtpeople+"";
//pager.PageSize 默认每页显示20条数据
DataSet ds = SqlHelper.GetPageRecords("GetPageRecordsFidld", "id", 10, pager.CurrentPageIndex, 2, 0, wherestr, tablename, "name,(select count(*) from peopleall where charindex(Area.name,duty)>0) as strCount");
GridView1.DataSource = ds;
this.GridView1.DataBind();
//获取查询的到的条数
CountData(wherestr);
}
解决方案 »
- C# 移动设备开发
- c#新手求助~串口通信
- 使用接口定义一个对象,并用这个接口实例化,然后调用接口中的抽象方法,会有什么情况?
- Winform中,DataGridView 模板列问题
- 想学编程,不知学什么好,敬请大侠们指教!
- 在线程里Show窗体为什么出不来?
- 关于datagrid的问题,如何使行宽不可由用户更改。(即行宽固定,不能通过拖拉的方式改变)
- 求助...利用ListView查看盘符下的文件夹和文件后,往上返回时无法显示,为什么?
- 十行小程序,有关多线程,高手来看看
- 如何随时刷新???????????
- tabcontrol+webbrowser如何获取网页标题
- c# IHTMLElement对象如何绑定js onclick事件
2, 在这里设置一个断点,DataSet ds = SqlHelper.GetPageRecords,看GetPageRecords中最后一个参数,到底是什么?