Click here to Skip to main content
15,887,856 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Quote:
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
<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 
Posted
Updated 12-May-17 19:17pm
v3
Comments
madhav_jain 10-May-17 0:59am    
I think that due to event OnRowEditing and OnRowUpdating both will be trigger.

1 solution

I guess its due to Update panel...check whether EnableEventValidation="false" or not..
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900