http://blog.csdn.net/w87875251l/archive/2010/11/02/5983301.aspx
如图,这样的报表如何实现?用什么报表?或用数据绑定控件可以吗?(如repeater),或用其他的??
注意:表中很多字段不是直接从数据库中读取的,而是根据数据库中表的字段用sql语句弄出来的,如已安装代理总数是:
----------总数
select count(computer_idn) as zongshu,company from
(select a.*,b.company from computer a,
(
select b.computer_idn,a.Company,b.IpAddress from gongsia a,BoundAdapter b where left(a.IpAddress,12)=left(b.IpAddress,12)
union
select b.computer_idn,a.Company,b.IpAddress from gongsib a,BoundAdapter b where a.ipaddress=b.ipaddress
) b where a.computer_idn=b.computer_idn
) a group by Company order by company我想着用reapter控件,但是认为行不通啊
如图,这样的报表如何实现?用什么报表?或用数据绑定控件可以吗?(如repeater),或用其他的??
注意:表中很多字段不是直接从数据库中读取的,而是根据数据库中表的字段用sql语句弄出来的,如已安装代理总数是:
----------总数
select count(computer_idn) as zongshu,company from
(select a.*,b.company from computer a,
(
select b.computer_idn,a.Company,b.IpAddress from gongsia a,BoundAdapter b where left(a.IpAddress,12)=left(b.IpAddress,12)
union
select b.computer_idn,a.Company,b.IpAddress from gongsib a,BoundAdapter b where a.ipaddress=b.ipaddress
) b where a.computer_idn=b.computer_idn
) a group by Company order by company我想着用reapter控件,但是认为行不通啊
解决方案 »
- |zyciis| 我在开发.NET用户控件的时候出现:System.Web.UI.Util”不可访问,因为它受保护级别限制,并不包含“_inputAttribu
- 请问web.config 会泄露吗?
- ExecuteScalar 要求已打开且可用的连接。连接的当前状态为已关闭。
- Excel线程在win2003 server服务器中退出不了的问题
- 我的reader为什么执行两次出来?疯了
- 登陆怎么也登陆不进去,总提示密码错误,高手给看看
- 为什么显示不出值?
- ASP.Net 下的联动菜单
- 请问如何在asp.net中使用sql插入数据的同时返回插入数据行的ID号
- ASP.NET如何把前台的变量传给后台?新手,求大神指教在线等,急
- 为什么手动刷新会进ispostback啊???
- asp.net中怎样用超链接传值?
这样的逻辑可以不?
{
dr[zongshu]=你算出来的。
}
<HeaderStyle ForeColor="White" HorizontalAlign="Center" />
<ItemTemplate>
<%# 你的方法() %>
</ItemTemplate>
</asp:TemplateField>
我的意思是那个链接表中有的整型字段是根据条件 用sql 中select count().....复杂的sql语句得到的,然后呈现到前台
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
binddrop();
bind();
//bind2();
}
}
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Repeater rep2 = (Repeater)e.Item.FindControl("Repeater2");
rep2.ItemDataBound += new RepeaterItemEventHandler(Repeater2_ItemDataBound);
//Label la = (Label)e.Item.FindControl("label1");
SqlConnection conn = db.CreateConnection(); DataRowView row = (DataRowView)e.Item.DataItem;
string str = row["company"].ToString();
string sql = "select count(computer_idn) as zongshu,company from (select a.*,b.company from computer a,(select b.computer_idn,a.Company,b.IpAddress from gongsia a,BoundAdapter b where left(a.IpAddress,12)=left(b.IpAddress,12) union select b.computer_idn,a.Company,b.IpAddress from gongsib a,BoundAdapter b where a.ipaddress=b.ipaddress ) b where a.computer_idn=b.computer_idn and b.Company='" + str + "') a group by Company order by company";
string sql1 = "select count(computer_idn)as geshu,Company from(select a.Computer_idn,b.ComPany,a.Reason,a.Vulnerability_Idn from CVDetected a,(select a.*,b.company from computer a,(select b.computer_idn,a.Company,b.IpAddress from gongsia a,BoundAdapter b where left(a.IpAddress,12)=left(b.IpAddress,12) union select b.computer_idn,a.Company,b.IpAddress from gongsib a,BoundAdapter b where a.ipaddress=b.ipaddress) b where a.computer_idn=b.computer_idn and b.Company='" + str + "') b where a.computer_idn=b.computer_idn and a.Vulnerability_Idn=2671) a group by Company order by Company";
SqlDataAdapter da = new SqlDataAdapter(sql, conn);
DataSet ds = new DataSet();
da.Fill(ds);
rep2.DataSource = ds;
rep2.DataBind();
}
} //倒数第二层绑定
protected void Repeater2_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Repeater rep3 = (Repeater)e.Item.FindControl("Repeater3");
DataRowView row = (DataRowView)e.Item.DataItem;
string str =row["company"].ToString(); DataRowView row1 = (DataRowView)e.Item.DataItem;
int a = Convert.ToInt32(row1["zongshu"]); SqlConnection conn = db.CreateConnection();
string sql = "select count(computer_idn)as geshu,Company from(select a.Computer_idn,b.ComPany,a.Reason,a.Vulnerability_Idn from CVDetected a,(select a.*,b.company from computer a,(select b.computer_idn,a.Company,b.IpAddress from gongsia a,BoundAdapter b where left(a.IpAddress,12)=left(b.IpAddress,12) union select b.computer_idn,a.Company,b.IpAddress from gongsib a,BoundAdapter b where a.ipaddress=b.ipaddress) b where a.computer_idn=b.computer_idn and b.Company='"+str+"') b where a.computer_idn=b.computer_idn and a.Vulnerability_Idn=2671) a group by Company order by Company";
conn.Open();
SqlDataAdapter da = new SqlDataAdapter(sql,conn);
DataSet ds = new DataSet();
da.Fill(ds,"a");
rep3.DataSource = ds.Tables["a"];
rep3.DataBind();
conn.Close();
//Response.Write(a / b);
} private void bind()
{
SqlConnection conn = db.CreateConnection();
string sql = "SELECT Company from gongsia union SELECT Company from gongsib";
DataTable dt = new DataTable();
//dt.Columns.Add("zongshu");
conn.Open();
SqlCommand cmd = new SqlCommand(sql, conn);
SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
dt.Load(dr);
Repeater1.DataSource = dt;
Repeater1.DataBind();
conn.Close();
}