动态GridView PageIndexChanging没有射击?

我有两个动态gridviews在左侧和另一个在右侧,我绑定这两个网格上的提交按钮单击。动态GridView PageIndexChanging没有射击?

我的问题是PageIndexChanging正在为我点击第一个,第二个不工作的网格工作ie)如果我先点击左侧网格,PageIndexChanging是单独为那个网格工作,而不是为右侧网格和反之。这里是我的代码

protected void lnkBTNSubmit_Click(object sender, EventArgs e) 

{

pnlLeft.Controls.Add(grdATASalesTrendleft);

dataResult = ObjAnalyzeTrendAnalysis.AnalyzeSalesTrendTables(requestID, "ATAT_1");

dataResult = ObjCommon.GetColumnAliasReportDetails(dataResult, "ATAT_1");

ObjSharedEntities.LeftTableData = dataResult;

BindGridDataLeft(grdATASalesTrendleft, ObjSharedEntities.LeftTableData);

grdATASalesTrendleft.Visible = true;

pnlRight.Controls.Add(grdATASalesTrendright);

dataResult = ObjAnalyzeTrendAnalysis.AnalyzeSalesTrendTables(requestID, "ATAT_5");

dataResult = ObjCommon.GetColumnAliasReportDetails(dataResult, "ATAT_5");

ObjSharedEntities.RightTableData = dataResult;

BindGridDataRight(grdATASalesTrendright, ObjSharedEntities.RightTableData);

grdATASalesTrendright.Visible = true;

}

protected void Page_Load(object sender, EventArgs e)

{

GridLoad();

}

private void GridLoad()

{

Leftgrid();

Rightgrid();

BindGridDataLeft(grdATASalesTrendleft, dataResult);

BindGridDataRight(grdATASalesTrendright, dataResult);

}

private void Leftgrid()

{

grdATASalesTrendleft = new GridView();

grdATASalesTrendleft.ID = "grdATASalesTrendleft";

grdATASalesTrendleft.AutoGenerateColumns = true;

grdATASalesTrendleft.EmptyDataText = "No data available.";

grdATASalesTrendleft.AllowPaging = true;

grdATASalesTrendleft.PagerSettings.Mode = PagerButtons.Numeric;

grdATASalesTrendleft.PagerSettings.Position = PagerPosition.Bottom;

grdATASalesTrendleft.PageSize = 15;

grdATASalesTrendleft.PagerStyle.BackColor = System.Drawing.Color.FromArgb(80, 124, 209);

ObjCommon.ApplyStylesForGridView(grdATASalesTrendleft);

grdATASalesTrendleft.PageIndexChanging += new GridViewPageEventHandler(grdATASalesTrendleft_PageIndexChanging);

}

private void BindGridDataLeft(GridView e, DataTable dataResult)

{

GridView grdATASalesTrend = (GridView)e;

grdATASalesTrend.DataSource = dataResult;

grdATASalesTrend.DataBind();

pnlLeft.Controls.Add(grdATASalesTrend);

}

void grdATASalesTrendleft_PageIndexChanging(object sender, GridViewPageEventArgs e)

{

GridView grdATASalesTrendleft = (GridView)sender;

grdATASalesTrendleft.PageIndex = e.NewPageIndex;

BindGridDataLeft(grdATASalesTrendleft, ObjSharedEntities.LeftTableData);

}

private void Rightgrid()

{

grdATASalesTrendright = new GridView();

grdATASalesTrendright.ID = "grdATASalesTrendright";

grdATASalesTrendright.AutoGenerateColumns = true;

grdATASalesTrendright.EmptyDataText = "No data available.";

grdATASalesTrendright.AllowPaging = true;

grdATASalesTrendright.PagerSettings.Mode = PagerButtons.Numeric;

grdATASalesTrendright.PagerSettings.Position = PagerPosition.Bottom;

grdATASalesTrendright.PageSize = 15;

grdATASalesTrendright.PagerStyle.BackColor = System.Drawing.Color.FromArgb(80, 124, 209);

ObjCommon.ApplyStylesForGridView(grdATASalesTrendright);

grdATASalesTrendright.PageIndexChanging += new GridViewPageEventHandler(grdATASalesTrendright_PageIndexChanging);

}

private void BindGridDataRight(GridView e, DataTable dataResult)

{

GridView grdATASalesTrend = (GridView)e;

grdATASalesTrend.DataSource = dataResult;

grdATASalesTrend.DataBind();

pnlRight.Controls.Add(grdATASalesTrend);

}

void grdATASalesTrendright_PageIndexChanging(object sender, GridViewPageEventArgs e)

{

GridView grdATASalesTrendright = (GridView)sender;

grdATASalesTrendright.PageIndex = e.NewPageIndex;

BindGridDataRight(grdATASalesTrendright, ObjSharedEntities.RightTableData);

}

任何建议吗?

回答:

你想要一个pageindex事件绑定你的网格吗?我的意思是一个传呼机点击两个网格。如果是这样,你必须绑定你的两个网格与新的pageIndex。

void grdATASalesTrendleft_PageIndexChanging(object sender, GridViewPageEventArgs e) 

{

GridView grdATASalesTrendleft = (GridView)sender;

grdATASalesTrendleft.PageIndex = e.NewPageIndex;

BindGridDataLeft(grdATASalesTrendleft, ObjSharedEntities.LeftTableData);

// add

grdATASalesTrendright.PageIndex = e.NewPageIndex;

BindGridDataRight(grdATASalesTrendright, ObjSharedEntities.RightTableData);

}

以上是 动态GridView PageIndexChanging没有射击? 的全部内容, 来源链接: utcz.com/qa/267023.html

回到顶部