我在devexpress网格视图数据显示中遇到问题。我通过c#将数据插入到网格视图中,当我执行时,它仅显示数据的第一页,而当我单击第二页等等时,则不显示数据。
代码如下:
web.config
<connectionStrings>
<add name="cn" connectionString="data source=xx;initial catalog=xx;user id=xx;password=xx;" providerName="System.Data.SQLClient"/></connectionStrings>
webform.aspx
<dx:ASPxGridView ID="Grid" runat="server" CssClass="auto-style5" Width="888px" ></dx:ASPxGridView>
webform.aspx.cs
using System;
using System.Web.UI;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;
public partial class WebForm1 : System.Web.UI.Page
{
DataTable dt = new DataTable();
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
ReadData();
}
}
public void ReadData()
{
try
{
using (SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["cn"].ConnectionString))
{
if (cn.State == System.Data.ConnectionState.Closed)
{
cn.Open();
}
using(SqlDataAdapter da= new SqlDataAdapter("Select RULETYPE,RULENAME,seqNo,SUM(CNT) as CNT,SUM(WFS_QTY) as QTY,(Select SUM(WFS_QTY) from RANK_DECISIVE where EQPtype = 'IASCAN' and DATADATE = '2018/06/12') as TTL_QTY From(Select t1.EQPID, t1.RULETYPE, t1.RULENAME, t1.CNT, t1.WFS_QTY, isNull(t2.rankingIndex, 999) as seqNo from(select a.EQPID, a.RULETYPE, a.RULENAME, a.CNT, a.WFS_QTY, b.ruleName as reportName from RANK_DECISIVE a, station b where a.EQPtype = 'IASCAN' and a.DATADATE = '2018/06/12' and RULETYPE = 'HIGHWIP' and a.EQPID = b.StationName) t1 left join rankingRule t2 on t1.reportName = t2.ReportName and t1.RULETYPE = t2.ruleName and t1.RULENAME = t2.reason) t3 Group by RULETYPE, RULENAME, seqNo", cn))
{
//Grid.PageIndex = newPageIndex;
da.Fill(dt);
Grid.DataSource = dt;
Grid.DataBind();
}
}
}
catch(Exception ex)
{
Response.Write(ex.Message);
}
}