C#简单嵌套flash读取数据的实现代码
效果:
说明:此效果只是简单的嵌套flash读取数据库中某两个字段的数据。(【js下载地址:http://xiazai.jb51.net/201311/yuanma/fusioncharts(jb51.net).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(jb51.net).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(jb51.net).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() + '"' + "/>'+";
}
}
}
}
下一篇: c#文本加密程序代码示例