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

Insert/Update Command Not firing while DeleteCommand works

14 Answers 254 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Hadi Teo
Top achievements
Rank 1
Hadi Teo asked on 18 Jun 2009, 08:09 AM
Hi There,

I have an issue with the Insert/Update Commands. Not sure why, but when the AJAX Enabled Web Application is working on its own from VS05, the Commands are triggered perfectly well. However, having deployed it to the CRM Server Environment, only the DeleteCommand works. I doubt the problem lies with the coding since it works well when its on stand-alone running via the VS05. Any suggestions?

Thanks.
PS: I have attached the working codes as an attachment in case you would be interested to view it.

Regards,
Christopher

ASPX:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="CUST_DivFeeApportionment._Default" %> 
 
<%@ Register Assembly="Telerik.Web.UI, Version=2009.1.527.20, Culture=neutral, PublicKeyToken=121fae78165ba3d4" 
    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="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" Skin="Vista" GridLines="None" 
            OnDeleteCommand="RadGrid1_DeleteCommand" OnInsertCommand="RadGrid1_InsertCommand" 
            OnUpdateCommand="RadGrid1_UpdateCommand" OnNeedDataSource="RadGrid1_NeedDataSource">  
            <MasterTableView CommandItemDisplay="Bottom" AutoGenerateColumns="False">  
                <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:GridButtonColumn CommandName="Delete" ButtonType="ImageButton" /> 
                    <telerik:GridBoundColumn DataField="New_DivFeeAppId" DataType="System.Guid" Visible="False" UniqueName="New_DivFeeAppId" ReadOnly="True" /> 
                </Columns> 
                <EditFormSettings> 
                    <EditColumn UniqueName="EditCommandColumn1">  
                    </EditColumn> 
                </EditFormSettings> 
            </MasterTableView> 
            <ValidationSettings EnableValidation="False" /> 
        </telerik:RadGrid> 
        <asp:SqlDataSource ID="SqlDataSource_DivNames" runat="server" ConnectionString="<%$ ConnectionStrings:CPG_MSCRMConnectionString %>" 
            SelectCommand="SELECT [New_name] FROM [New_distributionlist] WHERE (([New_Type] = @New_Type) AND ([DeletionStateCode] = @DeletionStateCode) AND ([statecode] = @statecode))">  
            <SelectParameters> 
                <asp:Parameter DefaultValue="1" Name="New_Type" Type="Int32" /> 
                <asp:Parameter DefaultValue="0" Name="DeletionStateCode" Type="Int32" /> 
                <asp:Parameter DefaultValue="0" Name="statecode" Type="Int32" /> 
            </SelectParameters> 
        </asp:SqlDataSource> 
    </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 System.Data.Sql;  
using System.Data.SqlClient;  
using CUST_DivFeeApportionment.CRMSDK;  
using Telerik.Web.UI;  
 
namespace CUST_DivFeeApportionment  
{  
    public partial class _Default : System.Web.UI.Page  
    {  
        protected static string projGuid = string.Empty;  
        protected static CrmService service;  
        protected static string deletionSC = "0";  
        protected static string sc = "0";  
 
        protected string OrgName = ConfigurationManager.AppSettings["OrgName"];  
        protected string crmServiceURL = ConfigurationManager.AppSettings["CRMServiceUrl"];  
 
        protected void Page_Load(object sender, EventArgs e)  
        {  
            if (!Page.IsPostBack)  
            {  
                // Set up the CRM Service.  
                CrmAuthenticationToken token = new CrmAuthenticationToken();  
                token.AuthenticationType = 0;  
                token.OrganizationName = OrgName;  
 
                service = new CrmService();  
                service.Url = crmServiceURL;  
                service.CrmAuthenticationTokenValue = token;  
                service.Credentials = System.Net.CredentialCache.DefaultCredentials;  
 
                projGuid = Request.QueryString["id"];  
                //hdProjGuid.Value = projGuid;  
                //The commented line that follows is for stand-alone testing of application  
                //hdProjGuid.Value = "6054A4CD-CF45-DE11-8F2B-0003FF046930";  
                //projGuid = "6054A4CD-CF45-DE11-8F2B-0003FF046930";  
            }  
        }  
 
        protected void RadGrid1_UpdateCommand(object source, GridCommandEventArgs e)  
        {  
            RadAjaxManager1.Alert("Update");  
        }  
 
        protected void RadGrid1_DeleteCommand(object source, GridCommandEventArgs e)  
        {  
            RadAjaxManager1.Alert("Delete");  
        }  
 
        protected void RadGrid1_InsertCommand(object source, GridCommandEventArgs e)  
        {  
            RadAjaxManager1.Alert("Insert");  
        }  
 
        public DataSet GetDataTable(string query)  
        {  
            SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["CPG_MSCRMConnectionString"].ToString());  
            SqlDataAdapter sqlDA = new SqlDataAdapter();  
            sqlDA.SelectCommand = new SqlCommand(query, sqlConn);  
 
            DataSet ds = new DataSet();  
 
            sqlConn.Open();  
            try 
            {  
                sqlDA.Fill(ds);  
            }  
            finally 
            {  
                sqlConn.Close();  
            }  
 
            return ds;  
        }  
 
        protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e)  
        {  
            //using StringBuilder to concatenate the Query String for the Select Command  
            //for the RadGrid  
            System.Text.StringBuilder query = new System.Text.StringBuilder();  
            query.Append("SELECT [New_name], [New_Amount], [New_PercentageofFee], [New_DivFeeAppId] FROM [New_DivFeeApp] WHERE [New_RelatingProjectId] = '");  
            query.Append(projGuid);  
            query.Append("' AND [DeletionStateCode] = '");  
            query.Append(deletionSC);  
            query.Append("' AND [statecode] = '");  
            query.Append(sc);  
            query.Append("'");  
 
            RadGrid1.DataSource = GetDataTable(query.ToString());  
        }  
    }  
}  
 

14 Answers, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 22 Jun 2009, 01:05 PM
Hello Hadi,

I afraid that I do not see anything that might cause different behavior on local machine and CRM Server Environment.
Please review if the code and config files are the same when running on both environments.

All the best,
Nikolay
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 24 Jun 2009, 08:15 AM
Hi Nikolay,

Well unfortunately, I am unable to find out what's going wrong too. I tried with the Non-AJAX version of RadControls and I'm having the same issue. My Insert and Update Commands are not triggered at all. Not sure what's going wrong. But I do appreciate your response.

Thanks.

Regards,
Christopher
0
Iana Tsolova
Telerik team
answered on 29 Jun 2009, 11:03 AM

Hello,

Does it make any difference if you change the GridEditCommandColumn to LinkButton? 
I also suggest that you try updating to the latest version of RadControls for ASP.NET AJAX and see if it works.

 
Greetings,

Iana
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
JJ
Top achievements
Rank 1
answered on 02 Oct 2009, 08:51 PM
I'm having a similar issue.  The event DOES fire for 'LinkButton' type but not for 'ImageButton' or 'PushButton' types.
0
Iana Tsolova
Telerik team
answered on 05 Oct 2009, 02:08 PM
Hi JJ,

Could you please confirm that you are using the latest version of RadControls for ASP.NET AJAX? Additionally, please specify how is your grid bound, e.g. server or client side. Any further information on your scenario and set up might help us get to the source of the issue you are facing.

Sincerely yours,
Iana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Henrik
Top achievements
Rank 1
answered on 18 Feb 2010, 02:29 PM
Hi Iana,

I had the same problem here with version 2009.3.1314: OnUpdateCommand was firing, but OnInsertCommand and OnCancelCommand were not.

The problem was solved when I removed the OnItemCommand (which was always firing).

Still looks like a bug you should take care of... ;-)

Best regards,
Henrik
0
Iana Tsolova
Telerik team
answered on 23 Feb 2010, 11:09 AM
Hi Henrik,

Indeed, it is suggested to handle each grid CRUD operation at one place, either in the specific event handle or in the ItemCommand event but both.

However, if you can provide the code for the ItemCommand and UpdateCommand event handles in your case, we can check it and turn back to you with our findings.

All the best,
Iana
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Henrik
Top achievements
Rank 1
answered on 28 Feb 2010, 04:54 PM
Hi Iana,

it looks like every command that is used in any way in the OnItemCommand won't fire its "specialized" OnXXCommand.

In my example, I wanted to implement some business rules in the OnItemCommand, like enabling controls depending on some settings. These business rules would apply to insert and update in the same way, so OnItemCommand looked like a good place to do this.
The actual insert or update should go into the OnInsertCommand / OnUpdateCommand, just to separate it from the settings-stuff.

You definitely have a point that every Event should only fire once, on the other hand it would have been nice to see both events triggered (see above). But it rather seems like some philosophical issue, than a serious bug.
Maybe you could just state this issue more clearly in the documentation (and the examples), it took a while to figure it out.

Best Regards,
Henrik
0
Iana Tsolova
Telerik team
answered on 04 Mar 2010, 10:16 AM
Hello Henrik,

Please take at look at this help article which describes what is the grid events sequence.

Kind regards,
Iana
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Dan
Top achievements
Rank 2
answered on 16 Apr 2010, 04:59 PM
Hi.  Was there a resolution to this problem?  Because I'm having the same issue.  I have an edit column and a delete column.  The edit button fires and executes as it should.  But the delete button does not work, does not fire the ItemCommand routine.  Here's the code:

<telerik:radgrid  ID="rgDoctors" runat="server" OnItemDataBound="rgDoctors_ItemDataBound" OnItemCommand="rgDoctors_ItemCommand">  
            <MasterTableView> 
                <EditFormSettings EditFormType="Template">  
                    <FormTemplate> 
                    ........  
                    </FormTemplate> 
                </EditFormSettings> 
                  
                <Columns> 
                    <telerik:GridBoundColumn HeaderText="ID" UniqueName="pk" DataField="no" 
                        Display="False" ReadOnly="True">  
                    </telerik:GridBoundColumn> 
                    .............  
                    <telerik:GridEditCommandColumn UniqueName="doctoredit" ButtonType="PushButton" ItemStyle-Width="60px" /> 
                    <telerik:GridButtonColumn ButtonType="PushButton" Text="Delete" CommandName="Delete" UniqueName="doctordelete" ItemStyle-Width="60px">  
                    </telerik:GridButtonColumn> 
                </Columns> 
            </MasterTableView> 
            <ClientSettings EnablePostBackOnRowClick="true" /> 
        </telerik:radgrid> 

Please reply if you know the work-around or solution to this.  Thanks.

Dan
0
Iana Tsolova
Telerik team
answered on 19 Apr 2010, 01:33 PM
Hello Dan,

Could you please check if altering the Delete column ButtonType property makes any difference?
Additionally, it would be of great help in finding the source of the problem if you send us a sample project illustrating you scenario and the issue. Thus we could debug it locally and turn back to you with a proper resolution.

Looking forward your reply,
Iana
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Dan
Top achievements
Rank 2
answered on 19 Apr 2010, 06:44 PM
I have isolated the problem in a stand-alone test page.  I will submit it as a support ticket attachment.

It is not the button type.

Thanks,
Dan
0
Apostol Apostolov
Top achievements
Rank 1
answered on 06 Jul 2010, 03:58 PM
Hey Telerik,

Any Advance on the issue? I am experiencing similar one.

Thanks,
Apostol
0
Dan
Top achievements
Rank 2
answered on 06 Jul 2010, 06:19 PM
Apostol,
The solution to my instance of this problem was removing this:

RadGrid1.MasterTableView.ExpandCollapseColumn.ButtonType = GridExpandColumnType.PushButton;


Cheers,
Dan
Tags
Grid
Asked by
Hadi Teo
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Hadi Teo
Top achievements
Rank 1
Iana Tsolova
Telerik team
JJ
Top achievements
Rank 1
Henrik
Top achievements
Rank 1
Dan
Top achievements
Rank 2
Apostol Apostolov
Top achievements
Rank 1
Share this question
or