2016-03-15 51 views
0

執行插入操作後,我無法退出編輯模式。插入不是通過radgrid完成的,而是被動地通過後面的代碼。我嘗試了一切,但完成插入後無法退出。單擊btnInsert後無法退出Telerik Radgrid編輯模式?

protected void btnInsertUpdate_Click(object sender, EventArgs e) 
    { 
     RadButton btnInsert = (RadButton)sender; 
     RadTextBox txtVisited = (RadTextBox)btnInsert.Parent.FindControl("txtVisited"); 
     RadTextBox txtDays = (RadTextBox)btnInsert.Parent.FindControl("txtDays"); 

     if (txtVisited.Text != "" & txtDays.Text != "" & !IsAsync) 
     { 

      string RECORD_UID = ds_01.InsertParameters["RECORD_UID"].DefaultValue; 

      string VISITED = txtVisited.Text; 
      string DAYS_ON_SITE = txtDays.Text; 

      DB db = new DB(); 
      SqlCommand cmd = new SqlCommand(); 
      db.ActiveDBConn = "dbConnection"; 
      cmd.CommandText = "ACP_CANADA_INSERT_NEW_RECORD_DETAILS"; 
      cmd.CommandType = System.Data.CommandType.StoredProcedure; 
      cmd.Parameters.AddWithValue("UID", RECORD_UID); 
      cmd.Parameters.AddWithValue("VISITED", VISITED); 
      cmd.Parameters.AddWithValue("DAYS_ON_SITE", DAYS_ON_SITE); 
      db.SQLStatement = cmd; 
      db.NonQuery(); 

      radgrid_1.MasterTableView.ClearEditItems(); 
     } 
    } 

<EditFormSettings EditFormType="Template" FormStyle-BackColor="#e1eaff" FormStyle-BorderColor="#006699" FormStyle-BorderWidth="10"> 
        <FormTemplate> 
         <div style="padding: 10px;"> 
          <div> 
           <telerik:RadLabel ID="lblVisited" runat="server" Text="Visited:"></telerik:RadLabel> 
           <telerik:RadTextBox ID="txtVisited" runat="server"></telerik:RadTextBox> 
           <br /> 
           <br /> 
           <telerik:RadLabel ID="lblDays" runat="server" Text="Days on Site:"></telerik:RadLabel> 
           <telerik:RadTextBox ID="txtDays" runat="server"></telerik:RadTextBox> 
          </div> 
          <br /> 
          <br /> 
          <telerik:RadButton id="btnInsertUpdate" runat="server" Text="Insert" OnClick="btnInsertUpdate_Click"></telerik:RadButton> 
          <telerik:RadButton id="btnCancel" text="Cancel" runat="server" causesvalidation="False" CommandName="Cancel"></telerik:RadButton> 
         </div> 
        </FormTemplate> 
       </EditFormSettings> 

回答

0

添加的CommandName等於「取消」給我我找...插入進行到數據庫和我退出編輯模式出來的行爲。

<telerik:RadButton id="btnInsert" runat="server" Text="Insert" OnClick="btnInsert_Click" CommandName="Cancel"></telerik:RadButton>