单击btnInsert后无法退出Telerik Radgrid编辑模式?

时间:2016-03-15 16:43:45

标签: c# asp.net 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>

1 个答案:

答案 0 :(得分:0)

添加CommandName等于&#34;取消&#34;给了我正在寻找的行为......对数据库执行插入操作,然后退出编辑模式。

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