当点击更新按钮时,发生了2次点击。我只想点击一下 对于那也是检查!回发但仍然没有工作。我已经读过其他Stackoverflow关于绑定网格的答案 更新我正在做的行但仍然无法正常工作。 我在pageindex和rowediting事件中绑定网格 需要帮助
后端代码
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">