首页 > 编程 > C# > 正文

C#简单嵌套flash读取数据的实现代码

2020-01-24 03:03:02
字体:
来源:转载
供稿:网友

效果:

说明:此效果只是简单的嵌套flash读取数据库中某两个字段的数据。(【js下载地址:http://xiazai.VeVB.COm/201311/yuanma/FusionCharts(VeVB.COm).js】 【swf下载地址:http://pan.baidu.com/s/1b2O9Q】    )

事件:初始化加载。

代码部分:

HTML:

复制代码 代码如下:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="flash/FusionCharts(VeVB.COm).js"type="text/javascript"></script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table width="920" align="center" border="0" cellspacing="0" cellpadding="0" id="flash">
            <tr>
                <td>
                    <div id="flashGO" style="width: 900px; border: 1px #ccc solid;">
                    </div>
                </td>
            </tr>
        </table>
    </div>
    </form>

    <script type="text/javascript">
        getchart('flash/Column3D(VeVB.COm).swf');
        function getchart(str) {
            var chart = new FusionCharts(str, "ChartId", "900", "400");
            chart.setDataXML('<?xml version="1.0" encoding="UTF-8" ?>'+
            '<chart caption="青苹果数据分析"  bgColor="#ffffff" xAxisName="试验室检测项目" yAxisName="总条数"' +
                ' numberPrefix="" sformatNumberScale="1"  syncAxisLimits="10" rotateValues="0" showSum="0" baseFontSize="12">' +
                /***生成柱状图*************************************************/
                       <%=flash %>
            /************************************************************/
                '</chart>');
            chart.render("flashGO");
        }
    </script>

</body>
</html>

后台:

复制代码 代码如下:

namespace qiantaoflash
{
    public partial class _Default : System.Web.UI.Page
    {
        SqlConnection con = new SqlConnection("server=NEWSPRING;database=QG_Mis;uid=sa;pwd=pass@word1");
        protected void Page_Load(object sender, EventArgs e)
        {
            GetData();
        }
        public string flash = string.Empty;
        protected void GetData()
        {
            string sql = string.Format(@"SELECT TOP 30 * FROM ly_tzk");
            DataSet ds = new DataSet();
            SqlDataAdapter sda = new SqlDataAdapter(sql, con);
            sda.Fill(ds);
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                flash += "'<set label=" + '"' + dr["xmmc"].ToString() + '"' + "value=" + '"' + dr["MenuID"].ToString() + '"' + "/>'+";
            }
        }
    }
}

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表