Chart系列(二):数据绑定
1.绑定到OleDbDataReader:
// Define the database query
string mySelectQuery="SELECT Name, Sales FROM REPS;";
// 。。。。。。
// Create a database reader
OleDbDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection); // Since the reader implements and IEnumerable, pass the reader directly into
// the DataBindTable method with the name of the Column to be used as the XValue
Chart1.DataBindTable(myReader, "Name");
2.绑定DataSource
// Define the database query
string mySelectQuery="SELECT * FROM REPS;"; // Create a database connection object using the connection string
OleDbConnection myConnection = new OleDbConnection(myConnectionString);
// Create a database command on the connection using query
OleDbCommand myCommand = new OleDbCommand(mySelectQuery, myConnection);
myConnection.Open();
// set chart data source - the data source must implement IEnumerable
chart1.DataSource = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
// Set series members names for the X and Y values
chart1.Series["Series 1"].XValueMember = "Name";
chart1.Series["Series 1"].YValueMembers = "Sales"; // Data bind to the selected data source
chart1.DataBind();
3.绑定Y值
// Create a database reader
OleDbDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection); // Since the reader implements and IEnumerable, pass the reader directly into
// the DataBind method with the name of the Column selected in the query
chart1.Series["Default"].Points.DataBindY(myReader, "GrossSales");
4.绑定X和Y
// Create a database reader
OleDbDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection); // Since the reader implements IEnumerable, pass the reader directly into
// the DataBind method with the name of the Column selected in the query
chart1.Series["Default"].Points.DataBindXY(myReader, "Name", myReader, "Sales");
Chart系列(二):数据绑定的更多相关文章
- WPF入门教程系列二十三——DataGrid示例(三)
DataGrid的选择模式 默认情况下,DataGrid 的选择模式为“全行选择”,并且可以同时选择多行(如下图所示),我们可以通过SelectionMode 和SelectionUnit 属性来修改 ...
- [知识库分享系列] 二、.NET(ASP.NET)
最近时间又有了新的想法,当我用新的眼光在整理一些很老的知识库时,发现很多东西都已经过时,或者是很基础很零碎的知识点.如果分享出去大家不看倒好,更担心的是会误人子弟,但为了保证此系列的完整,还是选择分享 ...
- highcharts 结合phantomjs纯后台生成图片系列二之php2
上篇文章中介绍了phantomjs的使用场景,方法. 本篇文章详细介绍使用php,highcharts 结合phantomjs纯后台生成图片.包含一步步详细的php代码 一.highcharts 结合 ...
- highcharts 结合phantomjs纯后台生成图片系列二之php
上篇文章中介绍了phantomjs的使用场景,方法.本篇文章详细介绍使用php,highcharts 结合phantomjs纯后台生成图片. 一.准备: 下载phantomjs解析插件,从 highc ...
- 前端构建大法 Gulp 系列 (二):为什么选择gulp
系列目录 前端构建大法 Gulp 系列 (一):为什么需要前端构建 前端构建大法 Gulp 系列 (二):为什么选择gulp 前端构建大法 Gulp 系列 (三):gulp的4个API 让你成为gul ...
- Web 开发人员和设计师必读文章推荐【系列二十九】
<Web 前端开发精华文章推荐>2014年第8期(总第29期)和大家见面了.梦想天空博客关注 前端开发 技术,分享各类能够提升网站用户体验的优秀 jQuery 插件,展示前沿的 HTML5 ...
- Web 前端开发人员和设计师必读文章推荐【系列二十八】
<Web 前端开发精华文章推荐>2014年第7期(总第28期)和大家见面了.梦想天空博客关注 前端开发 技术,分享各类能够提升网站用户体验的优秀 jQuery 插件,展示前沿的 HTML5 ...
- Web 开发精华文章集锦(jQuery、HTML5、CSS3)【系列二十七】
<Web 前端开发精华文章推荐>2014年第6期(总第27期)和大家见面了.梦想天空博客关注 前端开发 技术,分享各类能够提升网站用户体验的优秀 jQuery 插件,展示前沿的 HTML5 ...
- Web 前端开发人员和设计师必读精华文章【系列二十六】
<Web 前端开发精华文章推荐>2014年第5期(总第26期)和大家见面了.梦想天空博客关注 前端开发 技术,分享各类能够提升网站用户体验的优秀 jQuery 插件,展示前沿的 HTML5 ...
- Web 前端开发精华文章推荐(HTML5、CSS3、jQuery)【系列二十三】
<Web 前端开发精华文章推荐>2014年第2期(总第23期)和大家见面了.梦想天空博客关注 前端开发 技术,分享各类能够提升网站用户体验的优秀 jQuery 插件,展示前沿的 HTML5 ...
随机推荐
- 压缩js和css, IIS开启Etags, IIS开启Gzip
我们在前端页面性能调优时,经常会压缩js和css,下面列出几个比较好用的在线工具. http://www.jb51.net/tools/jsmin/index.htm http://javascrip ...
- HDU 1069&&HDU 1087 (DP 最长序列之和)
H - Super Jumping! Jumping! Jumping! Time Limit:1000MS Memory Limit:32768KB 64bit IO Format: ...
- Android自定义dialogdemo
很多时候,我们需要自己去定义dialog,目前我们就遇见了这样一个需求,我的想法是自己定义一个dialog,如果有list的话就使用listview,如果有msg的话就使用msg,并且取消和确定按钮也 ...
- top对僵尸进程的处理
ps --forest ASCII art process tree 2 怎样来清除僵尸进程: 1.改写父进程,在子进程死后要为它收尸.具体做法是接管SIGCHLD信 ...
- 《ASP.NET1200例》高亮显示ListView中的数据行并自动切换图片
aspx <script type="text/javascript"> var oldColor; function SetNewColor(Source) { ol ...
- Java for LeetCode 166 Fraction to Recurring Decimal
Given two integers representing the numerator and denominator of a fraction, return the fraction in ...
- 快速排序模板qsort(转载)
qsort 用 法: void qsort(void *base, int nelem, int width, int (*fcmp)(const void *,const void *)); 各 ...
- js将map转换成数组
/** * map转数组. * * @param {Map}map * map对象 * @return 数组 */ Share.map2Ary = function(map) { var list = ...
- [MACOS] Mac上的抓包工具Charles
转载自: http://blog.csdn.net/jiangwei0910410003/article/details/41620363 今天就来看一下Mac上如何进行抓包,之前有一篇文章介绍了使用 ...
- [Android Pro] ant 编译android工程
参考文章: http://blog.csdn.net/xyz_lmn/article/details/7268582?reload http://hubingforever.blog.163.com/ ...