[英]Updating Chart from Gridview - chart updates after Gridview Updates
I have a GridView and a chart. 我有一个GridView和一个图表。 I am plotting the time lapsed data from the Gridview.
我正在从Gridview绘制经过时间的数据。
Problem: The chart does not gets updated at the same time GridView does. 问题: GridView不会同时更新图表。 It is always one step back (requires one extra click).
它总是退后一步(需要额外点击一下)。
Mechanism: This is a time lapsed plot. 机制:这是一个延时图。 There is a start and end date and I am plotting them in particular way.
有一个开始和结束日期,我将以特殊方式绘制它们。 So I read the values in the Grid in page_load function
所以我在page_load函数中读取了网格中的值
foreach (GridViewRow row in GridView1.Rows)
{
// read the values that I need from the Grid
// and assign them to chart to create the chart
}
GridView1.DateBind();
Char1.DataBind();
I tried the page refresh approach but that did not work. 我尝试了页面刷新方法,但是没有用。 I am trying to figure out, am I doing something wrong?
我想弄清楚,我做错了什么吗? The 3D button works fine by the way and one of the thing it does wrong: it executes the actual query from SQLDataSource, not the one I created on the fly.
3D按钮可以顺便工作,而且它做错了一件事情:它从SQLDataSource执行实际的查询,而不是我即时创建的查询。
Suspicion: I am suspecting SQLDataSource for the problem. 怀疑:我怀疑是SQLDataSource的问题。 I have put one on ASPX page.
我在ASPX页面上放了一个。 I change the SQL Query on fly and I think that could be a problem?
我即时更改了SQL查询,我认为这可能是个问题?
Are you using some UpdatePanel? 您是否正在使用某些UpdatePanel?
Maybe you can try something like this: 也许您可以尝试这样的事情:
DataTable dt = new DataTable();
dt.Columns.Add("Column1");
dt.Columns.Add("Column2");
foreach (GridViewRow row in GridView1.Rows)
{
dt.Rows.Add(GridView1.HeaderRow.Cells[0].Text, row.Cells[0].Text);
}
cht.DataSource = dt;
cht.Series["serie"].XValueMembers = "Column1";
cht.Series["serie"].YValueMembers = "Column2";
cht.DataBind();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.