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:
C#:
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()); |
} |
} |
} |