• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

ASP.NET显示柱形图源码

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

有些报表,利用水晶报表过麻烦。并且水晶报表理论上必定是非免费的。又不是开源项目,使用与否,值得商讨。

这是我在开发项目中,写的一个简单的柱形图显示小程序。

<%@ Page language="c#" Codebehind="web_sheng.aspx.cs" AutoEventWireup="false" Inherits="hljtcpoa.cpadmin.web_sheng" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
 <HEAD>
  <title>web_sheng</title>
  <link href="http://www.cnblogs.com/../web/images/CSS.CSS" rel="stylesheet" type="text/css">
  <style>
body {
 font-size: 12px;
 line-height: 20px;
 color: #000000;
 background-image: url(../web/images/fbj.gif);

}
  </style>
  <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
 </HEAD>
 <body bgcolor="#FFFFFF" background="../web/images/fbj.gif">
  <form >
   <FONT face="宋体"></FONT>&nbsp;
   <asp:DataList >
    <ItemTemplate>
     <FONT face="宋体">
      <TABLE cellSpacing="0" cellPadding="0" width="440" border="0">
       <TR>
        <TD width="70" align="right" height="24" background="../web/images/7024.gif"><%# DataBinder.Eval(Container.DataItem,"sheng")%>&nbsp;</TD>
        <TD align="left" width="370"><img src="http://www.cnblogs.com/../web/images/zhu.gif" width='<%# len((decimal)DataBinder.Eval(Container.DataItem,"num"))%>' height="14" align=absmiddle>&nbsp;<font color=#999999><%# DataBinder.Eval(Container.DataItem,"num")%></font></TD>
       </TR>
      </TABLE>
     </FONT>
    </ItemTemplate>
   </asp:DataList>
  </form>
 </body>
</HTML>

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

namespace hljtcpoa.cpadmin
{
 /// <summary>
 /// web_sheng 的摘要说明。
 /// </summary>
 public class web_sheng : System.Web.UI.Page
 {
  protected System.Web.UI.WebControls.DataList DL;
     protected decimal j;
  private void Page_Load(object sender, System.EventArgs e)
  {
   DataSet ds=conn.dv("select top 1 * from index_sheng order by num desc");
   j=decimal.Parse(ds.Tables["Table"].Rows[0]["num"].ToString());
   ds.Clear();
   DL.DataSource=conn.dv("select * from index_sheng order by num desc");
   DL.DataBind();
  }
  public string len(decimal a)
  {
  decimal b=a*300/j;
  return b.ToString();
  
  }

  #region Web 窗体设计器生成的代码
  override protected void OnInit(EventArgs e)
  {
   //
   // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
   //
   InitializeComponent();
   base.OnInit(e);
  }
  
  /// <summary>
  /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  /// 此方法的内容。
  /// </summary>
  private void InitializeComponent()
  {   
   this.Load += new System.EventHandler(this.Page_Load);

  }
  #endregion
 }
}

   效果图:


  


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
说说ASP.NET的IsPostBack发布时间:2022-07-10
下一篇:
【转】提高ASP.Net应用程序性能的十大方法发布时间:2022-07-10
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap