Jay Anderson
Top achievements
Rank 1
Jay Anderson
asked on 16 Jun 2010, 10:19 PM
I am trying to use a GridDropDownColumn in my RadGrid, using InPlace editing. I have a GridDropDownColumn, which is linked to a User Table via business objects. I can view existing records, and update existing records. However, when I try to insert a new record, I get the catch-all 500 javascript error. I suspect it is missing the bindings when it tries to create the insert form.
I replaced the drop down with a bound column, using the user id (int) as the value, and the insert (and update) works, so I have isolated the issue to the drop down.
I have tried to code a Template column, but I am not good with binding data, so I am not getting the right data to display in the item template label or binding the correct user in the EditItemTemplate value. Also, on the update/insert step the user id is dropped from the values so i can't get that field when it returns to the InsertCommand (or UpdateCommand) method. I have tried populating the drop down in the ItemCreated method, and the ItemDataBound method.
I can post some code, but I was just wondering if someone had an example of a situation like this they can point me to. I have also used user edit forms, and I can come up with that solution also.
Thanks in advance for any insight.
I replaced the drop down with a bound column, using the user id (int) as the value, and the insert (and update) works, so I have isolated the issue to the drop down.
I have tried to code a Template column, but I am not good with binding data, so I am not getting the right data to display in the item template label or binding the correct user in the EditItemTemplate value. Also, on the update/insert step the user id is dropped from the values so i can't get that field when it returns to the InsertCommand (or UpdateCommand) method. I have tried populating the drop down in the ItemCreated method, and the ItemDataBound method.
I can post some code, but I was just wondering if someone had an example of a situation like this they can point me to. I have also used user edit forms, and I can come up with that solution also.
Thanks in advance for any insight.
3 Answers, 1 is accepted
0
Jay Anderson
Top achievements
Rank 1
answered on 17 Jun 2010, 08:37 PM
I tried putting a UserEditForm in the grid, and Update works, while Insert fails again. This is the error message, appears after Add New Record button is pressed in the grid:
Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500
The error occurs in MicrosoftAjax.debug.js.
The InsertCommand method is not entered, nor is the Page_Load on the User Edit Form.
I'll post some code:
User Control Code Behind:
User Control:
Grid Code Behind:
Grid Page:
Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500
The error occurs in MicrosoftAjax.debug.js.
The InsertCommand method is not entered, nor is the Page_Load on the User Edit Form.
I'll post some code:
User Control Code Behind:
using System; |
using System.Collections; |
using System.Collections.Generic; |
using System.Linq; |
using System.Reflection; |
using System.Text; |
using System.Web; |
using System.Web.UI; |
using System.Web.UI.HtmlControls; |
using System.Web.UI.WebControls; |
using Efco.Application.Web; |
using Efco.Business.Data; |
using Efco.Framework.WebControls; |
using Efco.Framework.WebControls.Base; |
using Efco.Business.Services.Caching; |
public partial class Agreement_CSGConsultantUserControl : EfcoBaseControl |
{ |
private CsgAgreementEfcoUserXRef csgAgreementEfcoUserXRef; |
private CsgAgreementEfcoUserXRefBL csgAgreementEfcoUserXRefBL; |
private EfcoUserBL efcoUserBL; |
public Object DataItem { get; set; } |
protected void Page_Load(object sender, EventArgs e) |
{ |
csgAgreementEfcoUserXRefBL = new CsgAgreementEfcoUserXRefBL(CurrentUser); |
efcoUserBL = new EfcoUserBL(CurrentUser); |
// if insert, the object will not be a FreightLoadCharge, therefore a new one must be constructed. |
// the object passed in will have a property attached, FreightLoadId. Construct a new FreightLoadCharge |
// object using this ID. |
if (DataItem is Telerik.Web.UI.GridInsertionObject) |
{ |
csgAgreementEfcoUserXRef = new CsgAgreementEfcoUserXRef(CurrentUser); |
//freightLoadCharge = freightLoadChargeBL.CreateNewFreightLoadCharge(Convert.ToInt32(((Telerik.Web.UI.GridInsertionObject)DataItem).GetPropertyValue("FreightLoadId"))); |
//SetFreightAdjustmentReasonValidators(false); |
//InsertButton.Enabled = true; |
} |
else |
{ |
if (DataItem != null) |
{ |
csgAgreementEfcoUserXRef = (CsgAgreementEfcoUserXRef) DataItem; |
//UpdateButton.Enabled = true; |
} |
} |
} |
protected void Page_PreRender(object sender, EventArgs e) |
{ |
BindDropDowns(); |
} |
private void BindDropDowns() |
{ |
WebHelper.BindDropDown(EfcoUserDropDownList, efcoUserBL.GetAllCsgConsultants().ToList(), "Name", "Id"); |
ListItem li = EfcoUserDropDownList.Items.FindByValue(csgAgreementEfcoUserXRef.EfcoUserId.ToString()); |
if (li != null) |
{ |
EfcoUserDropDownListEfcoUserDropDownList.SelectedIndex = EfcoUserDropDownList.Items.IndexOf(li); |
} |
} |
} |
User Control:
<%@ Import Namespace="Efco.Application.Web"%> |
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="CSGConsultantUserControl.ascx.cs" Inherits="Agreement_CSGConsultantUserControl" %> |
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> |
<%@ Register assembly="Efco.Framework.WebControls" namespace="Efco.Framework.WebControls" tagprefix="Easi" %> |
<Easi:EasiDataPanel runat="server" ID="CSGConsultantUpdatePanel"> |
<table> |
<tr> |
<td> |
<asp:Label ID="EfcoUserLabel" runat="server" Text="Efco User: " ></asp:Label> |
<asp:DropDownList ID="EfcoUserDropDownList" runat="server" TabIndex="0" Enabled='<%# (DataItem is Telerik.Web.UI.GridInsertionObject) %>' ></asp:DropDownList > |
</td> |
<td> |
<asp:Label ID="CommissionPercentageLabel" runat="server" Text="Commission Percentage: " ></asp:Label> |
<asp:TextBox ID="CommissionPercentageTextBox" runat="server" Text='<%# DataBinder.Eval( Container, "DataItem.CommissionPercentage" ) %>' TabIndex="1" ></asp:TextBox> |
</td> |
<td> |
<asp:Label ID="SequenceLabel" runat="server" Text="Sequence: " ></asp:Label> |
<asp:TextBox ID="SequenceTextBox" runat="server" Text='<%# DataBinder.Eval( Container, "DataItem.Sequence" ) %>' TabIndex="2" ></asp:TextBox> |
</td> |
</tr> |
<tr> |
<td> |
<asp:Button ID="UpdateButton" Text="Update" runat="server" CommandName="Update" Visible='<%# !(DataItem is Telerik.Web.UI.GridInsertionObject) %>' TabIndex="3" /> |
<asp:Button ID="InsertButton" Text="Insert" runat="server" CommandName="PerformInsert" Visible='<%# (DataItem is Telerik.Web.UI.GridInsertionObject) %>' TabIndex="4" /> |
<asp:Button ID="CancelButton" Text="Cancel" runat="server" CommandName="Cancel" CausesValidation="false" TabIndex="5" /> |
</td> |
</tr> |
</table> |
</Easi:EasiDataPanel> |
Grid Code Behind:
using System; |
using System.Collections; |
using System.Collections.Generic; |
using System.Globalization; |
using System.Web.UI; |
using System.Web.UI.WebControls; |
using Efco.Application.Web; |
using Efco.Business.Data; |
using Efco.Framework.WebControls; |
using Efco.Business.Services.Caching; |
using Efco.Framework.WebControls.Base; |
using Efco.Framework.WebControls.Master; |
using Efco.Utilities.Security; |
using Telerik.Web.UI; |
public partial class Agreement_ManageAgreement : EfcoBasePage |
{ |
#region Private Member |
private EasiCache _easiCache; |
private IAgreementBL _agreementBL; |
private bool saveAgreementStatus; |
private CsgAgreementEfcoUserXRefBL _csgAgreementEfcoUserXrefBL; |
private EfcoUserBL _efcoUserBL; |
private IList<CsgAgreementEfcoUserXRef> csgAgreementEfcoUserXRefs; |
#endregion |
#region Properties |
public Agreement Agreement { get; set; } |
public bool IsNew { get; set; } |
#endregion |
#region Page Events |
/// <summary> Page load, intialize the base class and set the agreement for events |
/// </summary> |
/// <param name="sender"></param> |
/// <param name="e"></param> |
protected void Page_Load(object sender, EventArgs e) |
{ |
_agreementBL = new AgreementBL(CurrentUser); |
_csgAgreementEfcoUserXrefBL = new CsgAgreementEfcoUserXRefBL(CurrentUser); |
_efcoUserBL = new EfcoUserBL(CurrentUser); |
if (Page.IsPostBack) |
//Pull Data Object from ViewState for Core Data Panel |
Agreement = (Agreement)AgreementDataPanel.RetrieveEasiDataFromViewState<Agreement>(); |
else |
{ |
//Pull Customer from Database or Create New |
GetAgreement(); |
//Bind all Additional Controls |
BindDropDowns(); |
SaveMessage.Visible = (WebHelper.IsSaved(Request) && !Agreement.ProjectContract.IsAddendum); |
} |
GetCsgAgreementEfcoUserXrefs(); |
BindAgreement(); |
Page.ClientScript.RegisterStartupScript(Page.GetType(), "PageFocus", "<script>SetPageFocus();TransactionTypeChange(" + Agreement.TransactionTypeId + ")</script>"); |
} |
/// <summary>Occurs just after all Controls have been initialized |
/// Best place to do binding since the controls will be fully established |
/// </summary> |
/// <param name="sender"></param> |
/// <param name="e"></param> |
protected override void Page_LoadComplete(object sender, EventArgs e) |
{ |
base.Page_LoadComplete(sender, e); |
this.EasiObjectState = Agreement.ObjectState; |
//Hide any Links based on the EasiObjectState |
if ((EasiObjectState != Efco.Utilities.Security.EasiObjectState.NotSet && |
EasiObjectState != Efco.Utilities.Security.EasiObjectState.OutOfGeoZone && |
EasiObjectState != Efco.Utilities.Security.EasiObjectState.SystemLock |
&& Agreement.ProjectContract.Project.Customer.CustomerStatusId == (int)CustomerStatusEnum.Active) |
&& Id > 0) |
{ |
if (Agreement.TransactionTypeId != (int)TransactionTypes.OpenAccount) |
{ |
if (Agreement.AgreementSegments.Count > 0) |
{ |
((IContentMaster)Master).SetNew("~/Agreement/AgreementSegments.aspx?Id=" |
+ Agreement.Id.ToString(CultureInfo.InvariantCulture), "Agreement Segment"); |
} |
else |
{ |
((IContentMaster)Master).SetNew("~/AgreementSegment/AgreementSegmentDetail.aspx?ParentId=" |
+ Agreement.Id.ToString(CultureInfo.InvariantCulture), "Agreement Segment"); |
} |
} |
((IContentMaster)Master).SetOpen( |
"~/AgreementSegment/AgreementSegmentDetail.aspx?Status=OpenSegment&ParentId=" + Id); |
} |
if (Agreement.TransactionTypeId == (int)TransactionTypes.OpenAccount) |
{ |
TransactionTypeDropDown.PageAccessLevel = FieldAccessType.Read; |
TransactionTypeDropDown.UsePageLevel = true; |
} |
// if AgreementStatus = 0 and CICC user, set access to Edit |
if (EasiObjectState != Efco.Utilities.Security.EasiObjectState.SystemLock) |
{ |
if (Agreement.AgreementStatusId == 0 && CurrentUser.IsCiccUser) |
{ |
WebControlHelper.ForceAccessType(AgreementStatusDropDown, FieldAccessType.Edit); |
} |
else |
{ |
WebControlHelper.ForceAccessType(AgreementStatusDropDown, FieldAccessType.Read); |
} |
} |
} |
/// <summary>Occurs just prior to render to set the view state on the data panel |
/// </summary> |
/// <param name="sender"></param> |
/// <param name="e"></param> |
protected void Page_PreRender(object sender, EventArgs e) |
{ |
AgreementDataPanel.StoreEasiDataInViewState<Agreement>(); |
} |
#endregion |
#region Protected Methods |
protected void Save_Clicked(object sender, EventArgs e) |
{ |
AgreementAgreement.SpecialShippingInstructions = Agreement.SpecialShippingInstructions.Replace("\r\n", " "); |
// if AgreementStatusId = 1 and access level is edit, value must have changed, set the agreement status date. |
if (saveAgreementStatus) |
{ |
Agreement.AgreementStatusDate = DateTime.Now; |
} |
_agreementBL.Save(Agreement); |
if (Agreement.AgreementSegments.Count == 0) |
{ |
//Since this is New and now properly saved...jump to Add AgreementSegment |
Response.Redirect("~/AgreementSegment/AgreementSegmentDetail.aspx?ParentId=" + Agreement.Id.ToString() + "&IsSaved=" + WebHelper.DateTimeToBase64(DateTime.Now)); |
} |
//Redirect to show / reload the saved data |
Response.Redirect(WebHelper.ChangeRequestQueryString(Request, "Id=" + Agreement.Id + "&IsSaved=" + WebHelper.DateTimeToBase64(DateTime.Now))); |
} |
/// <summary> If the record is locked don't show the edit buttons |
/// </summary> |
/// <returns></returns> |
protected bool ShowEditButtons() |
{ |
if (!Agreement.IsLocked || (PageAccessLevel == FieldAccessType.Edit)) |
return true; |
else |
return false; |
} |
///// <summary>Get a link for adding new agreement segment |
///// </summary> |
///// <returns></returns> |
//protected string GetLinkUrl() |
//{ |
//} |
#endregion |
#region Private Methods |
private void SetFreightTypes() |
{ |
IProjectContractCostComponentBL projectContractCostComponentsBL = new ProjectContractCostComponentBL(CurrentUser); |
//if (projectContractCostComponentsBL.IsLumpSumContractByAgreement(Agreement) |
// || Agreement.ProjectContract.LumpSumFreightAmount > 0) |
if (projectContractCostComponentsBL.IsLumpSumContractByAgreement(Agreement) |
|| Agreement.ProjectContract.LumpSumFreightStatusId > 0) |
{ |
ShippingFreightTypeDropDown.Items.Add(new ListItem("F - Lump sum freight", "5")); |
Agreement.ShippingFreightTypeId = (int)FrieghtTypes.LumpSumFreight; |
WebControlHelper.ForceAccessType(ShippingFreightTypeDropDown, FieldAccessType.Read); |
} |
else |
{ |
// cache freight types have Lump Sum Freight in them. This is not an acceptable option in the agreement and |
// agreement segment pages. Create a new object to add all but the Lump Sum freight type. (always id of 5) |
System.Collections.IList shippingFreightTypes; |
System.Collections.Generic.List<BindObject> newnewShippingFreightTypes = new List<BindObject>(); |
if (Agreement.ProjectContract.CICCApprovalBy == 0 || |
Agreement.ProjectContract.CICCAprovalDate > new DateTime(2009, 2, 1)) |
shippingFreightTypes = _easiCache.GetFreightTypes(false); |
else |
shippingFreightTypes = _easiCache.GetFreightTypes(true); |
foreach (BindObject o in shippingFreightTypes) |
{ |
if (o.Id != 5) |
{ |
newShippingFreightTypes.Add(o); |
} |
} |
WebHelper.BindDropDown(ShippingFreightTypeDropDown, newShippingFreightTypes); |
} |
} |
/// <summary>Bind the drop downs |
/// </summary> |
private void BindDropDowns() |
{ |
_easiCache = new EasiCache(); |
//For Cash Customers, show all SalesPersonGroups |
if (Agreement.ProjectContract.Project.Customer.IsCashCustomer) |
WebHelper.BindDropDown(SalesGroupDropDown, _easiCache.GetSalesPersonGroupsBySalesDistrict(0)); |
else |
WebHelper.BindDropDown(SalesGroupDropDown, _easiCache.GetSalesPersonGroupsBySalesDistrict(Agreement.ProjectContract.Project.Customer.SalesDistrictId)); |
WebHelper.BindDropDown(EngineerDropDown, _easiCache.GetEngineers()); |
SetFreightTypes(); |
WebHelper.BindDropDown(FieldServiceDropDown, _easiCache.GetFieldServiceUsers()); |
System.Collections.IList transactionTypes = new System.Collections.ArrayList(); |
if (Agreement.ProjectContract.ProjectContractTypeId== (Int32)ProjectContractTypes.PurchaseOrder) |
{ |
foreach (BindObject item in _easiCache.GetTransactionTypes()) |
{ |
if (item.Id != (Int32)TransactionTypes.Lease) |
{ |
transactionTypes.Add(item); |
} |
} |
} |
else |
transactionTypes = _easiCache.GetTransactionTypes(); |
WebHelper.BindDropDown(TransactionTypeDropDown, transactionTypes); |
System.Collections.IList agreementStatusTypes = new System.Collections.ArrayList(); |
WebHelper.BindDropDown(AgreementStatusDropDown, _easiCache.GetAgreementStatusValues()); |
//WebHelper.BindDropDown(AgreementStatusDropDown, agreementStatusTypes); |
} |
/// <summary>bind the agreement object to the data panel |
/// </summary> |
private void BindAgreement() |
{ |
ShippingAddress.Bind(Agreement.ShippingAddress); |
AgreementDataPanel.Bind(Agreement); |
//TelerikCSGConsultantPanel.Bind(Agreement); |
//CSGConsultantPanel.Bind(Agreement); |
} |
/// <summary>Get and build the agreement |
/// </summary> |
private void GetAgreement() |
{ |
if (Request["Status"] != null) |
{ |
switch (Request["Status"]) |
{ |
case "OpenProject": |
Agreement = _agreementBL.BuildOpenAgreement(ParentId, null, null, false); |
MasterTitle = "Agreement: New Open"; |
IsNew = true; |
break; |
case "OpenContract": |
Agreement = _agreementBL.BuildOpenAgreement(null, ParentId, null, false); |
MasterTitle = "Agreement: New Open"; |
IsNew = true; |
break; |
//case "OpenAgreement": |
// Agreement = _agreementBL.BuildAgreementForContract(ParentId); |
// Agreement.TransactionTypeId = (Int32) TransactionTypes.OpenAccount; |
// Agreement.Name = "Open Account"; |
// MasterTitle = "Agreement: New Open"; |
// IsNew = true; |
// break; |
case "CashAgreement": |
Agreement = _agreementBL.BuildOpenAgreement(ParentId, null, null, true); |
MasterTitle = "Agreement: New Cash Order"; |
IsNew = true; |
break; |
default: |
//TODO: Should raise Error here |
break; |
} |
ParentId = Agreement.ProjectContractId; |
} |
else |
{ |
if (Id > 0) |
{ |
IsNew = false; |
string requestType = _agreementBL.GetName(); |
if (Request["type"] != null) |
{ |
requestType = Request["type"]; |
} |
Agreement = _agreementBL.GetByIdAndType(Id, requestType); |
MasterTitle = Agreement.Id + " - " + Agreement.Name; |
} |
else |
{ |
IsNew = true; |
//Get info from Project Contract |
if (ParentId > 0) |
{ |
Agreement = _agreementBL.BuildAgreementForContract(ParentId); |
} |
else |
{ |
ErrorMessage.Text = |
"There was not a project id passed in. An agreement cannot be added without a Project being selected first."; |
ErrorPanel.Visible = true; |
} |
MasterTitle = "Add New Agreement"; |
} |
} |
} |
private void GetCsgAgreementEfcoUserXrefs() |
{ |
if (Agreement != null && Agreement.Id > 0) |
{ |
csgAgreementEfcoUserXRefs = _csgAgreementEfcoUserXrefBL.GetByCsgAgreementId(Agreement.Id); |
} |
else |
{ |
csgAgreementEfcoUserXRefs = new List<CsgAgreementEfcoUserXRef>(); |
} |
} |
#endregion |
#region Events |
/// <summary> |
/// Occurs when a user changes the AgreementStatus. Can be run multiple times, in case user |
/// changes their mind while still on the page. |
/// </summary> |
/// <param name="sender"></param> |
/// <param name="e"></param> |
protected void AgreementStatusDropDown_SelectedIndexChanged(object sender, EventArgs e) |
{ |
//Mark SuperSafety as Complete |
if (AgreementStatusDropDown.SelectedIndex == 0) |
{ |
saveAgreementStatus = false; |
} |
else |
{ |
saveAgreementStatus = true; |
} |
} |
protected void CsgConsultantEfcoUserObjectDataSource_ObjectCreating(object sender, ObjectDataSourceEventArgs e) |
{ |
EfcoUserBL csgConsultantEfcoUserBL = new EfcoUserBL(CurrentUser); |
e.ObjectInstance = csgConsultantEfcoUserBL; |
} |
protected void TelerikCSGConsultantRadGrid_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e) |
{ |
//GetCsgAgreementEfcoUserXrefs(); |
TelerikCSGConsultantRadGrid.DataSource = csgAgreementEfcoUserXRefs; |
} |
protected void TelerikCSGConsultantRadGrid_UpdateCommand(object source, GridCommandEventArgs e) |
{ |
Efco.Business.Data.CsgAgreementEfcoUserXRef csgAgreementEfcoUserXRef = new CsgAgreementEfcoUserXRef(CurrentUser); |
GridEditableItem item = e.Item as GridEditableItem; |
try |
{ |
Hashtable values = new Hashtable(); |
item.ExtractValues(values); |
int tempEfcoUserId = Int32.Parse(item.SavedOldValues["EfcoUserId"].ToString()); |
short tempSequence = Int16.Parse(item.SavedOldValues["Sequence"].ToString()); |
csgAgreementEfcoUserXRef = _csgAgreementEfcoUserXrefBL.GetBySequence(Agreement.Id, |
tempEfcoUserId, |
tempSequence); |
item.UpdateValues(csgAgreementEfcoUserXRef); |
//_csgAgreementEfcoUserXrefBL.Refresh(csgAgreementEfcoUserXRef); |
_csgAgreementEfcoUserXrefBL.Update(csgAgreementEfcoUserXRef); |
e.Item.OwnerTableView.Rebind(); |
} |
catch (Exception ex) |
{ |
TelerikCSGConsultantRadGrid.Controls.Add(new LiteralControl("Unable to update CSG Consultant. Reason: " + ex.Message)); |
} |
} |
protected void TelerikCSGConsultantRadGrid_InsertCommand(object source, GridCommandEventArgs e) |
{ |
Efco.Business.Data.CsgAgreementEfcoUserXRef csgAgreementEfcoUserXRef = new CsgAgreementEfcoUserXRef(CurrentUser); |
GridEditableItem item = e.Item as GridEditableItem; |
try |
{ |
Hashtable values = new Hashtable(); |
e.Item.OwnerTableView.ExtractValuesFromItem(values, item); |
//item.ExtractValues(values); |
csgAgreementEfcoUserXRef.AgreementId = Agreement.Id; |
csgAgreementEfcoUserXRef.EfcoUserId = Int32.Parse(values["EfcoUserId"].ToString()); |
csgAgreementEfcoUserXRef.CommissionPercentage = Decimal.Parse(values["CommissionPercentage"].ToString()); |
csgAgreementEfcoUserXRef.Sequence = Int16.Parse(values["Sequence"].ToString()); |
csgAgreementEfcoUserXRef.RecordCreatedDate = DateTime.Now; |
csgAgreementEfcoUserXRef.RecordCreatedEfcoUserId = CurrentUser.Id; |
csgAgreementEfcoUserXRef.RecordUpdateDate = DateTime.Now; |
csgAgreementEfcoUserXRef.RecordUpdatedEfcoUserId = CurrentUser.Id; |
_csgAgreementEfcoUserXrefBL.Save(csgAgreementEfcoUserXRef); |
csgAgreementEfcoUserXRefs.Add(csgAgreementEfcoUserXRef); |
e.Item.OwnerTableView.Rebind(); |
} |
catch (Exception ex) |
{ |
TelerikCSGConsultantRadGrid.Controls.Add(new LiteralControl("Unable to insert CSG Consultant. Reason: " + ex.Message)); |
} |
} |
protected void TelerikCSGConsultantRadGrid_DeleteCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) |
{ |
Efco.Business.Data.CsgAgreementEfcoUserXRef csgAgreementEfcoUserXRef = new CsgAgreementEfcoUserXRef(CurrentUser); |
GridDataItem item = e.Item as GridDataItem; |
try |
{ |
csgAgreementEfcoUserXRef.AgreementId = Agreement.Id; |
csgAgreementEfcoUserXRef = _csgAgreementEfcoUserXrefBL.GetById(Agreement.Id, |
Convert.ToInt32(item["EfcoUserId"].Text)); |
_csgAgreementEfcoUserXrefBL.Delete(csgAgreementEfcoUserXRef); |
if (csgAgreementEfcoUserXRefs.Contains(csgAgreementEfcoUserXRef)) |
{ |
csgAgreementEfcoUserXRefs.Remove(csgAgreementEfcoUserXRef); |
} |
e.Item.OwnerTableView.Rebind(); |
} |
catch (Exception ex) |
{ |
TelerikCSGConsultantRadGrid.Controls.Add(new LiteralControl("Unable to delete CSG Consultant. Reason: " + ex.Message)); |
} |
} |
#endregion |
protected void TelerikCSGConsultantRadGrid_ItemCreated(object sender, GridItemEventArgs e) |
{ |
if (e.Item is GridEditFormInsertItem) |
{ |
DropDownList dropDownList = (DropDownList) e.Item.FindControl("EfcoUserId"); |
dropDownList.DataSource = _efcoUserBL.GetAllCsgConsultants(); |
dropDownList.DataBind(); |
} |
} |
protected void TelerikCSGConsultantRadGrid_ItemDataBound(object sender, GridItemEventArgs e) |
{ |
if (e.Item is GridEditFormInsertItem) |
{ |
//GridEditableItem item = e.Item as GridEditableItem; |
//DropDownList list = item.FindControl("EfcoUserDropDown") as DropDownList; |
//list.DataSource = _efcoUserBL.GetAllCsgConsultants(); |
//list.DataTextField = "Name"; |
//list.DataValueField = "Id"; |
//list.DataBind(); |
//ListItem li = list.Items.FindByValue() |
} |
else if (e.Item is GridEditableItem && e.Item.IsInEditMode) |
{ |
//GridEditableItem item = e.Item as GridEditableItem; |
//DropDownList list = item.FindControl("EfcoUserId") as DropDownList; |
//list.DataSource = _efcoUserBL.GetAllCsgConsultants(); |
//list.DataTextField = "Name"; |
//list.DataValueField = "Id"; |
//list.DataBind(); |
} |
} |
} |
Grid Page:
<%@ Page Language="C#" MasterPageFile="~/MasterPages/EfcoContentEnglish.master" AutoEventWireup="true" CodeFile="AgreementDetail.aspx.cs" Inherits="Agreement_ManageAgreement" Title="300 Sales Plan - Agreement Detail" %> |
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %> |
<%@ Register assembly="Efco.Framework.WebControls" namespace="Efco.Framework.WebControls" tagprefix="Easi" %> |
<%@ Register src="../Address/Controls/Address.ascx" tagname="Address" tagprefix="EasiUc2" %> |
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> |
<%--<%@ Register src="TelerikCSGConsultantWebControl.ascx" tagname="TelerikCSGConsultantPanel" tagprefix="EasiUc3" %> |
--%> |
<asp:Content ID="Content1" ContentPlaceHolderID="EfcoContentEnglishHead" Runat="Server"> |
<script type="text/javascript"> |
function TransactionTypeChange(value) |
{ |
if (value==1) |
{ |
$('LeaseInfo').style.display=''; |
} |
else |
{ |
$('LeaseInfo').style.display='none'; |
} |
} |
</script> |
</asp:Content> |
<asp:Content ID="Content2" ContentPlaceHolderID="EfcoContentEnglishContent" Runat="Server"> |
<div id="MainForm" class="Holder"> |
<asp:Panel ID="ErrorPanel" runat="server" CssClass="ErrorMessage" Visible="false"> |
<asp:Label ID="ErrorMessage" runat="server"></asp:Label> |
</asp:Panel> |
<Easi:EasiDataPanel ID="AgreementDataPanel" runat="server" > |
<div id="BasicInfo" class="MainSection"> |
<div style="margin-top: 10px"><asp:Label ID="RecordLocked" CssClass="LockedLabel" Visible='<%# Agreement.IsLocked %>' runat="server" Text="* Record Is Locked!"></asp:Label></div> |
<div class="TableHeader">Contract/Invoicing Information</div> |
<div class="SaveButtons"> |
<asp:Panel ID="SaveMessage" runat="server" Visible="false" CssClass="SaveMessage"> |
<span>Agreement Saved!</span></asp:Panel> |
<%--<div class="TopLinks"> |
<asp:HyperLink ID="AddAgreementSegmentLink" Visible='<%# !IsNew %>' runat="server" Text="Add New Agreement Segment" NavigateUrl='<%# GetLinkUrl() %>'></asp:HyperLink> |
</div>--%> |
<Easi:EasiLinkButton ID="UpdateButton" runat="server" |
TableName="Agreement" FieldName="Id" |
CheckForDirty="False" class="ShowLink" Text="Save" |
OnClick="Save_Clicked" /> |
</div> |
<table class="Info" cellpadding="0" cellspacing="0" > |
<tr style="height: 10px"><td></td></tr> |
<tr class="TableRowStandard"> |
<td style="width: 175px" class="LabelHeader"> |
<Easi:EasiLabel ID="ProjectContractLabel" runat="server" Text="Project Contract" |
AssociatedControlID="ProjectLink" ></Easi:EasiLabel> |
</td> |
<td> |
<Easi:EasiHyperLink ID="ProjectLink" runat="server" FieldName="ProjectContractId" TableName="Agreement" |
NavigateUrl='<%# "~/ProjectContract/ProjectContractDetail.aspx?Id=" + Agreement.ProjectContract.Id %>' |
Text='<%# Agreement.ProjectContract.Name %>' |
></Easi:EasiHyperLink> |
</td> |
</tr> |
<tr class="TableRowStandard"> |
<td class="LabelHeader" style="width: 175px" > |
<Easi:EasiLabel ID="IdHeaderLabel" runat="server" Text="Agreement Id" Visible='<%# !IsNew %>' |
AssociatedControlID="IdLabel" ></Easi:EasiLabel> |
</td> |
<td style="width: 175px;"> |
<Easi:EasiLabel ID="IdLabel" runat="server" Visible='<%# !IsNew %>' |
TableName="Agreement" FieldName="Id" ></Easi:EasiLabel> |
</td> |
</tr> |
<tr class="TableRowStandard"> |
<td style="width: 175px" class="LabelHeader"> |
<Easi:EasiLabel ID="NameLabel" runat="server" Text="Agreement Description" |
AssociatedControlID="NameTextBox" ></Easi:EasiLabel> |
</td> |
<td> |
<Easi:EasiTextBox ID="NameTextBox" runat="server" FieldName="Name" MaxLength="100" Width="300" |
TableName="Agreement" ></Easi:EasiTextBox> |
</td> |
</tr> |
<tr class="TableRowStandard"> |
<td colspan="2"> |
<table> |
<tr> |
<td style="width: 175px" class="LabelHeader"> |
<Easi:EasiLabel ID="TransactionTypeLabel" runat="server" Text="Transaction Type" |
AssociatedControlID="TransactionTypeDropDown" ></Easi:EasiLabel> |
</td> |
<td style="width: 125px"> |
<Easi:EasiDropDownList ID="TransactionTypeDropDown" runat="server" onchange="TransactionTypeChange(this.value)" |
FieldName="TransactionTypeId" TableName="Agreement" IgnoreOutOfRangeException="true" ></Easi:EasiDropDownList> |
</td> |
<td style="width: 175px" class="LabelHeader"> |
<Easi:EasiLabel ID="AgreementStatusLabel" runat="server" Text="Agreement Status" |
AssociatedControlID="AgreementStatusDropDown" ></Easi:EasiLabel> |
</td> |
<td style="width: 200px"> |
<Easi:EasiDropDownList ID="AgreementStatusDropDown" runat="server" OnSelectedIndexChanged="AgreementStatusDropDown_SelectedIndexChanged" |
FieldName="AgreementStatusId" TableName="Agreement" IgnoreOutOfRangeException="true" ></Easi:EasiDropDownList> |
</td> |
</tr> |
</table> |
</td> |
</tr> |
<tr class="TableRowStandard"> |
<td style="width: 175px" class="LabelHeader"> |
<Easi:EasiLabel ID="SalesPersonGroupLabel" runat="server" Text="Territory Manager" |
AssociatedControlID="SalesGroupDropDown" ></Easi:EasiLabel> |
</td> |
<td> |
<Easi:EasiDropDownList ID="SalesGroupDropDown" runat="server" |
FieldName="SalesPersonGroupId" TableName="Agreement" IgnoreOutOfRangeException="true" ></Easi:EasiDropDownList> |
</td> |
</tr> |
<tr> |
<td colspan="2"> |
<asp:RequiredFieldValidator ID="NameRequired" runat="server" ErrorMessage="Agreement Description is Required.<br />" |
ControlToValidate="NameTextBox" Display="Dynamic"></asp:RequiredFieldValidator><asp:CompareValidator runat="server" id="TransactionTypeDropDownRequired" Operator="GreaterThan" Type="Integer" Display="Dynamic" |
ValueToCompare="0" ControlToValidate="TransactionTypeDropDown" ErrorMessage = "You must select a Transaction Type.<br />" /> |
<asp:CompareValidator runat="server" id="SalesGroupSelected" Operator="GreaterThan" Type="Integer" |
Display="Dynamic" ValueToCompare="0" ControlToValidate="SalesGroupDropDown" |
ErrorMessage = "You must select a Territory Manager Group.<br />" /> |
<%--<asp:RangeValidator runat="server" id="MinimumRentPeriodTextBoxValidator" Type="Integer" |
Display="Dynamic" MinimumValue="2" MaximumValue="520" ControlToValidate="MinimumRentPeriodTextBox" |
ErrorMessage = "Minimun Rent period must be between 2 and 520 weeks.<br />" />--%> |
</td> |
</tr> |
<tr style="height: 10px"><td></td></tr> |
</table> |
<br /> |
<div id="LeaseInfo" class="MainSection" > |
<div class="TableHeader">Rental Details</div><table class="Info" cellpadding="0" cellspacing="0" width="100%"> |
<tr style="height: 10px"><td></td></tr> |
<tr class="TableRowStandard" id="MinRentRow"> |
<td style="width: 175px" class="LabelHeader"> |
<Easi:EasiLabel ID="MinimumRentPeriodLabel" runat="server" Text="Minimum Rent Period" |
AssociatedControlID="MinimumRentPeriodTextBox" ></Easi:EasiLabel></td><td> |
<Easi:EasiTextBox ID="MinimumRentPeriodTextBox" runat="server" |
FieldName="MinimumRentPeriod" TableName="Agreement" ></Easi:EasiTextBox></td></tr><tr class="TableRowStandard"> |
<td style="width: 175px" class="LabelHeader"> |
<Easi:EasiLabel ID="MinimumRentInvoiceGeneratedLabel" runat="server" Text="Minimum Rent Invoice Generated" |
AssociatedControlID="MinimumRentInvoiceGeneratedCheckBox" ></Easi:EasiLabel></td><td> |
<Easi:EasiCheckBox ID="MinimumRentInvoiceGeneratedCheckBox" runat="server" |
FieldName="MinimumRentInvoiceGenerated" TableName="Agreement" /> |
</td> |
<td style="width: 175px" class="LabelHeader"> |
<Easi:EasiLabel ID="MinimumRentInvoiceAmountLabel" runat="server" Text="Minimum Rent Invoice Amount" |
AssociatedControlID="MinimumRentInvoiceAmountTextBox" ></Easi:EasiLabel></td><td> |
<Easi:EasiTextBox ID="MinimumRentInvoiceAmountTextBox" runat="server" |
FieldName="MinimumRentInvoiceAmount" MaxLength="50" TableName="Agreement" |
DisplayType="Currency" ></Easi:EasiTextBox></td></tr><tr> |
<td colspan="4"> |
<asp:CustomValidator id="MinimumRentInvoiceAmountTextBoxValidator" runat="server" |
ControlToValidate="MinimumRentInvoiceAmountTextBox" |
RegEx="^(\d{0,9}\.\d{0,2}|\d{0,9})$" |
ErrorMessage="* The minimum rent invoice amount is not a valid value.<br />" |
display="dynamic" /> |
</td> |
</tr> |
<tr style="height: 10px"><td></td></tr> |
</table> |
</div> |
<br /> |
<div id="ServiceInfo" class="MainSection" > |
<div class="TableHeader">Service Information</div> |
<table class="Info" cellpadding="0" cellspacing="0" width="100%"> |
<tr style="height: 10px"><td colspan="4"></td></tr> |
<tr class="TableRowStandard"> |
<td style="width: 175px" class="LabelHeader"> |
<Easi:EasiLabel ID="FieldServiceLabel" runat="server" Text="Field Service" |
AssociatedControlID="FieldServiceDropDown" ></Easi:EasiLabel> |
</td> |
<td> |
<Easi:EasiDropDownList ID="FieldServiceDropDown" runat="server" |
FieldName="FieldServiceId" TableName="Agreement" IgnoreOutOfRangeException="true" ></Easi:EasiDropDownList> |
</td> |
<td class="LabelHeader"> |
<Easi:EasiLabel ID="EngineerLabel" runat="server" Text="Engineer" |
AssociatedControlID="EngineerDropDown" ></Easi:EasiLabel> |
</td> |
<td> |
<Easi:EasiDropDownList ID="EngineerDropDown" runat="server" |
FieldName="EngineerEfcoUserId" TableName="Agreement" IgnoreOutOfRangeException="true" ></Easi:EasiDropDownList> |
</td> |
</tr> |
<tr class="TableRowStandard"> |
<td colspan="4"> |
<Easi:EasiDataPanel runat="server" ID="TelerikCsgAgreementDataPanel" > |
<telerik:RadGrid ID="TelerikCSGConsultantRadGrid" runat="server" |
AutoGenerateColumns="False" GridLines="None" |
ondeletecommand="TelerikCSGConsultantRadGrid_DeleteCommand" |
oninsertcommand="TelerikCSGConsultantRadGrid_InsertCommand" |
onneeddatasource="TelerikCSGConsultantRadGrid_NeedDataSource" |
onupdatecommand="TelerikCSGConsultantRadGrid_UpdateCommand" |
ShowStatusBar="True" |
onitemcreated="TelerikCSGConsultantRadGrid_ItemCreated" |
OnItemDataBound="TelerikCSGConsultantRadGrid_ItemDataBound" > |
<HeaderContextMenu EnableAutoScroll="True"> |
</HeaderContextMenu> |
<ValidationSettings EnableValidation="false" /> |
<MasterTableView CommandItemDisplay="Top" EditMode="EditForms" DataKeyNames="AgreementId, EfcoUserId" > |
<RowIndicatorColumn> |
<HeaderStyle Width="20px" /> |
</RowIndicatorColumn> |
<ExpandCollapseColumn> |
<HeaderStyle Width="20px" /> |
</ExpandCollapseColumn> |
<Columns> |
<telerik:GridBoundColumn DataField="AgreementId" HeaderText="Agreement ID" DefaultInsertValue="" UniqueName="AgreementNumber" |
Visible="False"> |
</telerik:GridBoundColumn> |
<telerik:GridDropDownColumn |
EnableEmptyListItem="true" |
DataField="EfcoUserId" |
DataSourceId="CsgConsultantEfcoUserObjectDataSource" |
DataType="System.Int32" |
DefaultInsertValue="Please Select a Value" |
HeaderText="Efco User" |
SortExpression="Name" |
UniqueName="EfcoUserId" |
ListTextField="Name" |
ListValueField="Id"> |
</telerik:GridDropDownColumn> |
<telerik:GridBoundColumn DataField="CommissionPercentage" HeaderText="Commission Percentage" DefaultInsertValue="" |
UniqueName="CommissionPercentage"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="Sequence" HeaderText="Sequence" DefaultInsertValue="" UniqueName="Sequence"> |
</telerik:GridBoundColumn> |
<telerik:GridEditCommandColumn> |
</telerik:GridEditCommandColumn> |
<telerik:GridButtonColumn CommandName="Delete" Text="Delete" |
UniqueName="column"> |
</telerik:GridButtonColumn> |
</Columns> |
<%-- <EditFormSettings> |
<EditColumn UniqueName="EditCommandColumn1"> |
</EditColumn> |
</EditFormSettings> |
--%> <EditFormSettings EditFormType="WebUserControl" UserControlName="CSGConsultantUserControl.ascx" > |
<EditColumn UniqueName="EditCommandColumn1" > |
</EditColumn> |
</EditFormSettings> |
</MasterTableView> |
</telerik:RadGrid> |
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" |
EnablePageHeadUpdate="true"> |
<AjaxSettings> |
<telerik:AjaxSetting AjaxControlID="TelerikCSGConsultantRadGrid"> |
<UpdatedControls> |
<telerik:AjaxUpdatedControl ControlID="TelerikCSGConsultantRadGrid" LoadingPanelID="TelerikCsgAgreementDataPanel" /> |
</UpdatedControls> |
</telerik:AjaxSetting> |
</AjaxSettings> |
</telerik:RadAjaxManager> |
</Easi:EasiDataPanel> |
</td> |
</tr> |
<tr> |
<td colspan="4"> |
<asp:CompareValidator runat="server" id="FieldServiceDropDownRequired" Operator="GreaterThan" Type="Integer" |
Display="Dynamic" ValueToCompare="0" ControlToValidate="FieldServiceDropDown" |
ErrorMessage = "You must select a Field Service User.<br />" /> |
<asp:CompareValidator runat="server" id="EngineerSelected" Operator="GreaterThan" Type="Integer" Display="Dynamic" |
ValueToCompare="0" ControlToValidate="EngineerDropDown" ErrorMessage = "You must select an Engineer.<br />" /> |
</td> |
</tr> |
<tr style="height: 10px"><td colspan="4"></td></tr> |
</table> |
</div> |
<br /> |
<div id="ShippingInfo" class="MainSection" > |
<div class="TableHeader">Shipping Information</div><table class="Info" cellpadding="0" cellspacing="0" width="100%"> |
<tr style="height: 10px"><td></td></tr> |
<tr class="TableRowStandard"> |
<td class="LabelHeader"> |
<Easi:EasiLabel ID="ShippingFreightTypeLabel" runat="server" Text="Shipping Freight Type" |
AssociatedControlID="ShippingFreightTypeDropDown" ></Easi:EasiLabel> |
</td> |
<td> |
<Easi:EasiDropDownList ID="ShippingFreightTypeDropDown" runat="server" |
FieldName="ShippingFreightTypeId" TableName="Agreement" IgnoreOutOfRangeException="true" ></Easi:EasiDropDownList> |
</td> |
</tr> |
<tr style="height: 5px"><td></td></tr> |
<tr class="TableRowStandard"> |
<td class="LabelHeader" valign="top"> |
<Easi:EasiLabel ID="SpecialShippingInstructionsLabel" runat="server" Text="Special Shipping Instructions" |
AssociatedControlID="SpecialShippingInstructionsTextBox" ></Easi:EasiLabel> |
</td> |
<td> |
<Easi:EasiTextBox ID="SpecialShippingInstructionsTextBox" runat="server" |
TableName="Agreement" FieldName="SpecialShippingInstructions" |
MaxLength="84" |
Width="500" ></Easi:EasiTextBox> |
</td> |
</tr> |
<tr> |
<td colspan="2"> |
<asp:CompareValidator runat="server" id="ShippingFreightTypeSelected" Operator="GreaterThan" Type="Integer" |
Display="Dynamic" ValueToCompare="0" ControlToValidate="ShippingFreightTypeDropDown" |
ErrorMessage = "You must select a Shipping Freight Type.<br />" /> |
</td> |
</tr> |
<tr style="height: 10px"><td></td></tr> |
</table> |
</div> |
<br /> |
<div id="ShppingAddress" class="MainSection" > |
<div class="TableHeader">Shipping Address</div><div class="Info"> |
<asp:UpdatePanel ID="ShippingAddressUpdatePanel" runat="server" UpdateMode="Conditional"> |
<ContentTemplate> |
<EasiUc2:Address ID="ShippingAddress" runat="server" HideHeaderInfo="true" |
CurrentAddressType="ShippingAddress" AllowChangeType="false" ParentTableName="Agreement" |
ParentFieldName="ShippingAddressId" IsNew='<%# IsNew %>' /> |
</ContentTemplate> |
</asp:UpdatePanel> |
</div> |
</div> |
<br /> |
<div class="SaveButtons"> |
<Easi:EasiLinkButton ID="SaveButtonBottom" runat="server" |
TableName="Agreement" FieldName="Id" |
CheckForDirty="False" class="ShowLink" Text="Save" |
OnClick="Save_Clicked" /> |
</div> |
<br /> |
<br /> |
</div> |
</Easi:EasiDataPanel> |
</div> |
<asp:ObjectDataSource ID="CsgConsultantEfcoUserObjectDataSource" runat="server" |
DataObjectTypeName="Efco.Business.Data.EfcoUser" |
SelectMethod="GetAllCsgConsultants" |
TypeName="Efco.Business.Data.EfcoUserBL" |
onobjectcreating="CsgConsultantEfcoUserObjectDataSource_ObjectCreating" |
DeleteMethod="Delete" InsertMethod="Save" UpdateMethod="Save"> |
</asp:ObjectDataSource> |
<telerik:RadCodeBlock runat="server" ID="RadCodeBlock1"> |
<script type="text/javascript"> |
function WebForm_OnSubmit() { |
DisableButtons(true); |
if (typeof (ValidatorOnSubmit) == "function" && ValidatorOnSubmit() == false) { |
DisableButtons(false); |
return false; |
} |
//submitonce(theForm); |
return true; |
} |
var dataGridDocument = document.getElementById("<%# AgreementDataPanel.FindControl("TelerikCsgAgreementDataPanel") %>"); |
Sys.WebForms.PageRequestManager.getInstance().add_pageLoading(endRequest); |
function endRequest(sender, e){ |
DisableButtons(false); |
} |
function DisableButtons(b) { |
if (b) { |
SetButtonToLoading($('<%= UpdateButton.ClientID %>')); |
SetButtonToLoading($('<%= SaveButtonBottom.ClientID %>')); |
} |
else { |
SetButtonBack($('<%= UpdateButton.ClientID %>')); |
SetButtonBack($('<%= SaveButtonBottom.ClientID %>')); |
} |
} |
SetForChangeCheck(theForm,$('<%= SaveMessage.ClientID %>')); |
</script> |
</telerik:RadCodeBlock> |
</asp:Content> |
0
Hello Jay,
The reasons for this error may vary and that is why I suggest you perform some troubleshooting using the tips from this documentation topic:
http://www.telerik.com/help/aspnet-ajax/web-resources-troubleshooting.html
and the blog post pointed below:
http://blogs.telerik.com/atanaskorchev/posts/08-07-18/web_resources_demystified_part_3_troubleshooting.aspx
I hope this helps.
Best wishes,
Pavlina
the Telerik team
The reasons for this error may vary and that is why I suggest you perform some troubleshooting using the tips from this documentation topic:
http://www.telerik.com/help/aspnet-ajax/web-resources-troubleshooting.html
and the blog post pointed below:
http://blogs.telerik.com/atanaskorchev/posts/08-07-18/web_resources_demystified_part_3_troubleshooting.aspx
I hope this helps.
Best wishes,
Pavlina
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
Jay Anderson
Top achievements
Rank 1
answered on 21 Jun 2010, 06:04 PM
Found the error, using Fiddler. DefaultInsertValue was not set to a value that could be parsed to Int32.
Changed that value, now it is working. Valuable tool, folks, Fiddler. Get it now!
Changed that value, now it is working. Valuable tool, folks, Fiddler. Get it now!