Hello,
I am trying to use a custom radfilter datafield editor. I am not binding the radfilter directly to anything.... i am merely using it to provide the user an interface to create an advanced grouped query - and then using it to get the strongly typed where condition.
the field I am having an issue with is technically a numerical field editor - although the fields they are referring to in the database are bit fields.
as a result, i am trying to only allow the user to choose between the values 0 and 1 through a dropdown box (with displayed values of "true" and "false" instead.
this seems to work.... once. it will add the field editor once, but when i try to add another expression item, it runs into an error.
it looks like i am not passing on some editor variable from the base object... and possibly missing an override, but i am not sure.
the code for the editor is below:
and the error i get is as follows:
any help with troubleshooting this issue would be MUCH appreciated. thanks!
I am trying to use a custom radfilter datafield editor. I am not binding the radfilter directly to anything.... i am merely using it to provide the user an interface to create an advanced grouped query - and then using it to get the strongly typed where condition.
the field I am having an issue with is technically a numerical field editor - although the fields they are referring to in the database are bit fields.
as a result, i am trying to only allow the user to choose between the values 0 and 1 through a dropdown box (with displayed values of "true" and "false" instead.
this seems to work.... once. it will add the field editor once, but when i try to add another expression item, it runs into an error.
it looks like i am not passing on some editor variable from the base object... and possibly missing an override, but i am not sure.
the code for the editor is below:
public class RadFilterBooleanDropDownEditor : RadFilterDataFieldEditor { protected override void CopySettings(RadFilterDataFieldEditor baseEditor) { base.CopySettings(baseEditor); var editor = baseEditor as RadFilterBooleanDropDownEditor; if (editor != null) { //DataSourceID = editor.DataSourceID; //DataTextField = editor.DataTextField; //DataValueField = editor.DataValueField; } } public override System.Collections.ArrayList ExtractValues() { ArrayList list = new ArrayList(); list.Add(int.Parse(_combo.SelectedValue)); return list; } public override void InitializeEditor(System.Web.UI.Control container) { _combo = new RadComboBox(); _combo.ID = "MyCombo"; _combo.Width = System.Web.UI.WebControls.Unit.Pixel(48); _combo.Items.Add(new RadComboBoxItem("True","1")); _combo.Items.Add(new RadComboBoxItem("False","0")); //container.Controls[1].Visible = false; container.Controls.Add(_combo); } public override void SetEditorValues(System.Collections.ArrayList values) { if (values != null && values.Count > 0) { if (values[0] == null) return; var item = _combo.FindItemByValue(values[0].ToString()); if (item != null) item.Selected = true; } } public string DataTextField { get { return (string)ViewState["DataTextField"] ?? string.Empty; } set { ViewState["DataTextField"] = value; } } public string DataValueField { get { return (string)ViewState["DataValueField"] ?? string.Empty; } set { ViewState["DataValueField"] = value; } } public string DataSourceID { get { return (string)ViewState["DataSourceID"] ?? string.Empty; } set { ViewState["DataSourceID"] = value; } } private RadComboBox _combo; }and the error i get is as follows:
Object reference not set to an instance of an object.Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.Stack Trace: [NullReferenceException: Object reference not set to an instance of an object.] Telerik.Web.UI.RadFilterDataFieldEditor.CreateEditorFrom(RadFilterDataFieldEditor baseEditor) +9 Telerik.Web.UI.RadFilterSingleExpressionItem.SetupFunctionInterface(Control container) +55 Telerik.Web.UI.RadFilterExpressionItem.CreateFunctionalInterface() +89 Telerik.Web.UI.RadFilterExpressionItem.InitializeItem() +24 Telerik.Web.UI.RadFilter.CreateFilterItems() +284 Telerik.Web.UI.RadFilter.CreateControlHierarchy() +34 Telerik.Web.UI.RadFilter.CreateChildControls() +90 System.Web.UI.Control.EnsureChildControls() +102 System.Web.UI.Control.FindControl(String id, Int32 pathOffset) +20 System.Web.UI.Control.FindControl(String id, Int32 pathOffset) +365 System.Web.UI.Control.FindControl(String id, Int32 pathOffset) +365 System.Web.UI.Control.FindControl(String id, Int32 pathOffset) +365 System.Web.UI.Control.FindControl(String id, Int32 pathOffset) +365 System.Web.UI.Control.FindControl(String id, Int32 pathOffset) +365 System.Web.UI.Control.FindControl(String id, Int32 pathOffset) +365 System.Web.UI.Page.FindControl(String id) +38 System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) +287 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +878any help with troubleshooting this issue would be MUCH appreciated. thanks!