第五天上班,做不出来就滚蛋了,应届生急求

w87875251l 2010-11-05 09:49:01
http://blog.csdn.net/w87875251l/archive/2010/11/02/5983301.aspx

我要完成第二个图的一个报表的项目,但是遇到问题了,我只做到第一个图那了,用的repeater三层嵌套,
private void bind()
{
SqlConnection conn = db.CreateConnection();
string sql = "SELECT Company from gongsia union SELECT Company from gongsib";
DataTable dt = new DataTable();
conn.Open();
SqlCommand cmd = new SqlCommand(sql, conn);
SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
dt.Load(dr);
Repeater1.DataSource = dt;
Repeater1.DataBind();
conn.Close();
}
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);
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();
}
}
// <asp:Label ID="label1" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"company") %>' ></asp:Label>

//倒数第二层绑定
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();

}
}
第四列是用第三列除以第二列作为第四列的值,能不能实现?不能的话应该怎么办?
...全文
1609 102 打赏 收藏 转发到动态 举报
写回复
用AI写文章
102 条回复
切换为时间正序
请发表友善的回复…
发表回复
sonda 2010-11-10
  • 打赏
  • 举报
回复
oooo,,,不错。
lovexiu0924 2010-11-09
  • 打赏
  • 举报
回复
貌似这个帖子的回帖率老高老高的啊 不错不错啊!
misswangjinfeng 2010-11-09
  • 打赏
  • 举报
回复
加油啦!!!
柳泉青云 2010-11-09
  • 打赏
  • 举报
回复
闭门修炼三个月,出来后瞄都不妙这破公司!!!
n109214114 2010-11-09
  • 打赏
  • 举报
回复
好乱的代码。
Jaliyah 2010-11-09
  • 打赏
  • 举报
回复
……不是你死,就是它亡
ASPNETCHENGXU 2010-11-09
  • 打赏
  • 举报
回复
sql方面的建议去sql板块问问,那的牛人什么样的sql难题都能解决
xf198903 2010-11-09
  • 打赏
  • 举报
回复
只为拿一分
yan267 2010-11-09
  • 打赏
  • 举报
回复
电信哦,楼主很不错的单位。

不过为啥不用存储过程构建临时表,而用嵌套的办法玩?
qh617 2010-11-09
  • 打赏
  • 举报
回复
代码看的我 头好大
huangjingyan2008 2010-11-09
  • 打赏
  • 举报
回复
好庞大的代码。。。
wangdetian168 2010-11-09
  • 打赏
  • 举报
回复
你用一个repeater 绑定下面的数据 用headtemplate 做表头就可以了
别递烟哥不会 2010-11-09
  • 打赏
  • 举报
回复
sql好长··帮你顶个
  • 打赏
  • 举报
回复
先把关系,逻辑弄清楚在做。
没弄清楚之前,怎么做,都是没用的。
  • 打赏
  • 举报
回复
用 GridView 来显示,数据吧,比较容易。
代码也简单。
  • 打赏
  • 举报
回复
每个人都是从菜鸟过来的,努力就好,多看看别人的代码。
如果项目很大,建议用三层。
anbin0814 2010-11-08
  • 打赏
  • 举报
回复
你还没弄过难的报表,我们上次弄一个难的里面的样式也要,也是动态的样式,根据选择的值不同,调用不同的样式,

你这样的报表最好不要用控件,最原始的方法用字符串去拼


或者用xslt去生成
wujingjing520 2010-11-08
  • 打赏
  • 举报
回复
加油!!! 你们公司真不人性化~~
w87875251l 2010-11-08
  • 打赏
  • 举报
回复
健在,马上就快滚蛋了
baysos 2010-11-08
  • 打赏
  • 举报
回复
LZ还健在???????????????????
加载更多回复(71)

62,074

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧