需要两次单击updatebutton才能更新gridview中的行? [英] Need to click the updatebutton twice to update the row in gridview ?

查看:57
本文介绍了需要两次单击updatebutton才能更新gridview中的行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

引用:

当点击更新按钮时,发生了2次点击。我想只需点击一下即可查看!回发但它仍然没有工作。我已经读过其他Stackoverflow关于绑定网格更新我正在做的行的答案,但仍然无法正常工作。我在pageindex绑定网格和rowediting事件需要帮助



INFO:我的ASPX页面有3个左右更新面板

Curently 2 click are happening for on Update button to fire.i want only single click for that am also checking on !postback but still it's not working.which i have read in other Stackoverflow answer about binding the grid on updating the row which i am doing but still it's not working. i am binding the grid in pageindex and rowediting event need help

INFO: my ASPX page has around 3 update panel





后端代码





Backend code

protected void BindGridSubMeter()
{
	ConnectionMRI conMRI = new ConnectionMRI();
	DataSet ds = conMRI.NabersSubMetergetData(ddlBldgId.SelectedItem.Value);
	TextExclusions.Text = ds.Tables(1).Rows(0).Item(0).ToString();
	var _with1 = GridSubMeter;
	_with1.DataSource = ds.Tables(0);
	_with1.DataBind();

}


protected void GridSubMeter_RowEditing(object sender, System.Web.UI.WebControls.GridViewEditEventArgs e)
{
	GridSubMeter.EditIndex = e.NewEditIndex;
	this.BindGridSubMeter();
}

protected void GridSubmeter_PageIndexChanging(object sender, System.Web.UI.WebControls.GridViewPageEventArgs e)
{
	GridSubMeter.PageIndex = e.NewPageIndex;
	this.BindGridSubMeter();
}


protected void GridSubMeter_RowUpdating(object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e)
{
	TextBox txtMeterIdn = (TextBox)GridSubMeter.Rows(e.RowIndex).FindControl("txtMeterIdn");
	TextBox txCTFact = (TextBox)GridSubMeter.Rows(e.RowIndex).FindControl("txCTFact");
	TextBox txReadStartDate = (TextBox)GridSubMeter.Rows(e.RowIndex).FindControl("txReadStartDate");
	TextBox txReadEndDate = (TextBox)GridSubMeter.Rows(e.RowIndex).FindControl("txReadEndDate");
	TextBox txStartKwh = (TextBox)GridSubMeter.Rows(e.RowIndex).FindControl("txStartKwh");
	TextBox txEndKwh = (TextBox)GridSubMeter.Rows(e.RowIndex).FindControl("txEndKwh");
	TextBox txBillPer = (TextBox)GridSubMeter.Rows(e.RowIndex).FindControl("txBillPer");

	string MeterIdn = txtMeterIdn.Text.Trim.ToString();
	decimal CTFact = Convert.ToDecimal(txCTFact.Text);
	System.DateTime ReadStartDate = System.DateTime.Parse(txReadStartDate.Text);
	System.DateTime ReadEndDate = System.DateTime.Parse(txReadEndDate.Text);
	decimal StartKwh = Convert.ToDecimal(txStartKwh.Text);
	decimal EndKwh = Convert.ToDecimal(txEndKwh.Text);
	decimal billper = Convert.ToDecimal(txBillPer.Text);

	string leasid = GridSubMeter.Rows(e.RowIndex).Cells(0).Text.Trim.ToString();
	string suitid = GridSubMeter.Rows(e.RowIndex).Cells(1).Text.Trim.ToString();
	string occupant = GridSubMeter.Rows(e.RowIndex).Cells(2).Text.Trim.ToString();
	GridSubMeter.EditIndex = -1;
	ConnectionMRI conMRI = new ConnectionMRI();
	conMRI.NaberSubmeter(ddlBldgId.SelectedItem.Value, leasid, suitid, occupant, MeterIdn, CTFact, ReadStartDate, ReadEndDate, StartKwh, EndKwh,
	billper);
	BindGridSubMeter();

}





ASPX



ASPX

<asp:GridView ID="GridSubMeter" runat="server" AutoGenerateColumns="false" DataKeyNames="leasid" AllowPaging="True" OnPageIndexChanging="GridSubmeter_PageIndexChanging" OnRowEditing="GridSubMeter_RowEditing" OnRowUpdating="GridSubMeter_RowUpdating">  





我的尝试:





What I have tried:

Curently 2 click are happening for on Update button to fire.i want only single click for that am also checking on !postback but still it's not working.which i have read in other Stackoverflow answer about binding the grid on updating the row which i am doing but still it's not working. i am binding the grid in pageindex and rowediting event need 

推荐答案

我想它是由于Update面板...检查EnableEventValidation =假或不......
I guess its due to Update panel...check whether EnableEventValidation="false" or not..


这篇关于需要两次单击updatebutton才能更新gridview中的行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆