This is a migrated thread and some comments may be shown as answers.

RadGrid1.InsertCommand not firing

7 Answers 319 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Karl Wilkens
Top achievements
Rank 1
Karl Wilkens asked on 15 Apr 2009, 06:36 PM
Hi,

We have a Radgrid with 12 template columns that contain radcombboxes, checkboxes, date pickers and regular text box fields. All of those have .net validation controls on them. My developer is losing her mind over a current issue wherein the Insert command is not firing. That is to say, that when you add a new record and click insert, a postback occurs, but the RadGrid1.InsertCommand never fires. When you click Insert, the grid simply reloads and the edit screen disappears and no record is inserted. The delete command DOES fire. It is auto generated. Here is our grid definition.

       <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True"  AllowSorting="True" GridLines="None" Skin="Web20" AutoGenerateColumns="False" AutoGenerateDeleteColumn="True" AutoGenerateEditColumn="True" AllowFilteringByColumn="True" >

To troubleshoot and narrow the issue down, we have tried

1. Removing all the client side validation - that did not have any effect.
2. Commenting out the ItemCommand and ItemCreated commands

If anyone out there has any ideas on where to look, I would greatly appreciate it.

7 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 16 Apr 2009, 05:21 AM
Hi Karl,

In the above given aspx code I cannot find the Event declaration for InsertCommand. Can you confirm whether you have set it in the code behind or not.

ASPX:
 
 <telerik:RadGrid ID="RadGrid1"  DataSourceID="SqlDataSource1" runat="server"  OnInsertCommand="RadGrid1_InsertCommand" > 

CS:
 
 protected void RadGrid1_InsertCommand(object source, GridCommandEventArgs e) 
    { 
 
    } 

You can also refer the following code Library that I submitted to get more details on performing manual Insert/Update/Delete operation.
Manual Insert/Update/Delete operations using Auto-generated editform with sql statements from the code-behind

Shinu
0
Hadi Teo
Top achievements
Rank 1
answered on 10 Jun 2009, 10:20 AM
Hi Shinu,

Was wondering if you are able to help me? I'm having a similar problem where my InsertCommand and UpdateCommand does not get fired. I have put into the methods, javascript alerts so that it would be rather obvious when triggered, however the alerts are not firing. In debug mode, the methods with breakpoints are not hit as well. I will attach my codes below for your viewing.

ASPX:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="CUST_DivFeeAppGridAJAX._Default" %> 
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml" > 
<head runat="server" > 
    <title></title>  
</head> 
<body style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; padding-top: 0px; margin: 0px;">  
    <form id="form1" runat="server" > 
        <asp:ScriptManager ID="ScriptManager1" runat="server" /> 
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">  
            <AjaxSettings> 
                <telerik:AjaxSetting AjaxControlID="RadGrid1">  
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> 
                    </UpdatedControls> 
                </telerik:AjaxSetting> 
            </AjaxSettings> 
        </telerik:RadAjaxManager> 
    <div> 
        <telerik:RadGrid ID="RadGrid1" runat="server" SkinID="Vista" Skin="Vista" DataSourceID="SqlDataSource_DivFeeApp" GridLines="None" OnDeleteCommand="RadGrid1_DeleteCommand" OnInsertCommand="RadGrid1_InsertCommand" OnUpdateCommand="RadGrid1_UpdateCommand">  
            <MasterTableView CommandItemDisplay="Bottom" AutoGenerateColumns="False" DataSourceID="SqlDataSource_DivFeeApp">  
                <Columns> 
                    <telerik:GridDropDownColumn DataField="New_name" HeaderText="Division" SortExpression="New_name" 
                        UniqueName="New_name" DataSourceID="SqlDataSource_DivNames" ListValueField="New_name" ListTextField="New_name">  
                    </telerik:GridDropDownColumn> 
                    <telerik:GridBoundColumn DataField="New_PercentageofFee" DataType="System.Double" 
                        HeaderText="Percentage (%)" SortExpression="New_PercentageofFee" UniqueName="New_PercentageofFee" DataFormatString="{0:F2}">  
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="New_Amount" DataType="System.Decimal" HeaderText="Amount ($)" 
                        SortExpression="New_Amount" UniqueName="New_Amount" DataFormatString="{0:F2}">  
                    </telerik:GridBoundColumn> 
                    <telerik:GridEditCommandColumn ButtonType="ImageButton"></telerik:GridEditCommandColumn> 
                    <telerik:GridClientDeleteColumn ButtonType="ImageButton"></telerik:GridClientDeleteColumn> 
                </Columns> 
                <EditFormSettings> 
                    <EditColumn UniqueName="EditCommandColumn1">  
                    </EditColumn> 
                </EditFormSettings> 
            </MasterTableView> 
            <ValidationSettings EnableValidation="False" /> 
        </telerik:RadGrid> 
        <asp:SqlDataSource ID="SqlDataSource_DivFeeApp" runat="server" ConnectionString="<%$ ConnectionStrings:CPG_MSCRMConnectionString %>" 
            SelectCommand="SELECT [New_name], [New_PercentageofFee], [New_Amount] FROM [New_DivFeeApp] WHERE ([New_RelatingOpportunityId] = @New_RelatingOpportunityId)">  
            <SelectParameters> 
                <asp:ControlParameter Name="New_RelatingOpportunityId" ControlID="hdOppGuid" /> 
            </SelectParameters> 
        </asp:SqlDataSource> 
        <asp:SqlDataSource ID="SqlDataSource_DivNames" runat="server" ConnectionString="<%$ ConnectionStrings:CPG_MSCRMConnectionString %>" 
            SelectCommand="SELECT [New_name] FROM [New_divison]">  
        </asp:SqlDataSource> 
        <asp:HiddenField ID="hdOppGuid" runat="server" /> 
    </div> 
    </form> 
</body> 
</html> 
 

C#:
using System;  
using System.Data;  
using System.Configuration;  
using System.Collections;  
using System.Web;  
using System.Web.Security;  
using System.Web.UI;  
using System.Web.UI.WebControls;  
using System.Web.UI.WebControls.WebParts;  
using System.Web.UI.HtmlControls;  
using Telerik.Web.UI;  
 
namespace CUST_DivFeeAppGridAJAX  
{  
    public partial class _Default : System.Web.UI.Page  
    {  
 
        protected void Page_Load(object sender, EventArgs e)  
        {  
        }  
 
        protected void RadGrid1_UpdateCommand(object source, GridCommandEventArgs e)  
        {  
            ClientScript.RegisterStartupScript(GetType(), "Javascript""<script>alert(\"Test Update.\")</script>");  
        }  
 
        protected void RadGrid1_DeleteCommand(object source, GridCommandEventArgs e)  
        {  
            ClientScript.RegisterStartupScript(GetType(), "Javascript""<script>alert(\"Test Insert.\")</script>");  
        }  
 
        protected void RadGrid1_InsertCommand(object source, GridCommandEventArgs e)  
        {  
            ClientScript.RegisterStartupScript(GetType(), "Javascript""<script>alert(\"Insert is completed.\")</script>");  
        }  
    }  
}  
 


Please advise.

Thanks.

Regards,
Christopher
0
Daniel
Telerik team
answered on 12 Jun 2009, 11:15 PM
Hello Hadi,

I created a simple demo based on the code you posted in this thread. May I ask you to test it locally?

Best regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Hadi Teo
Top achievements
Rank 1
answered on 16 Jun 2009, 02:48 AM

Hi There,

Well I'm able to trigger the Update, Delete and Insert Command methods now by setting the SQL Datasource with the following:

ASPX:

<asp:SqlDataSource ID="SqlDataSource_DivFeeApp" runat="server" ConnectionString="<%$ ConnectionStrings:CPG_MSCRMConnectionString %>" 
            SelectCommand="SELECT [New_name], [New_PercentageofFee], [New_Amount] FROM [New_DivFeeApp] WHERE (([New_RelatingOpportunityId] = @New_RelatingOpportunityId) AND (DeletionStateCode = @DeletionStateCode))" 
            InsertCommand="" 
            UpdateCommand="" 
            DeleteCommand="" > 
            <SelectParameters> 
                <asp:ControlParameter ControlID="hdOppGuid" Name="New_RelatingOpportunityId" PropertyName="Value" Type="String" /> 
                <asp:Parameter DefaultValue="0" Name="DeletionStateCode" Type="Int32" /> 
            </SelectParameters> 
        </asp:SqlDataSource> 

Therefore, even though the SQL Statement is empty, the Methods as mentioned above are still triggered. However, I've got a problem with regards to the RadGrid staying in InsertMode even after insert is completed. I have tried the following codes to aid in trying to switch the InsertMode off, but it has been to no avail.

C#:

RadGrid1.MasterTableView.IsItemInserted = false;   
RadGrid1.MasterTableView.Rebind(); 

Please advise. Thanks.

Regards,
Christopher

0
Hadi Teo
Top achievements
Rank 1
answered on 16 Jun 2009, 02:57 AM
Hi Daniel,

Thanks for the sample project. It did help and I appreciate the help provided too.

Regards,
Christopher
0
Stanley
Top achievements
Rank 1
answered on 02 Nov 2009, 04:07 PM
I bumped into the same issue when IFRAME ASP.NET into Dynamics CRM 4; then, I switched over to standard ASP.NET Gridview control, ... but same issue.
After some tracing, I finally figured out a workaround: if I deploy ASP.NET under the same "Microsoft Dynamics CRM" Site both RadGrid and GridView will not work; but if I create a new "Site" and deploy ASP.NET App over there, it works fine. (My guess is that, "CRM Site" will want to control/overwrite-part-of those Apps under its tree, thus changed those ASP.NETs' behavor and cause them not functioning as expected.)
Hope it helps...
0
Sahil
Top achievements
Rank 1
answered on 24 Nov 2011, 12:26 PM
same problem here...also have problem with update command...please suggest
Tags
Grid
Asked by
Karl Wilkens
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Hadi Teo
Top achievements
Rank 1
Daniel
Telerik team
Stanley
Top achievements
Rank 1
Sahil
Top achievements
Rank 1
Share this question
or