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

NullReferenceException using RadFilter in Page_Load

2 Answers 68 Views
Filter
This is a migrated thread and some comments may be shown as answers.
Kurtis
Top achievements
Rank 1
Kurtis asked on 17 Jun 2016, 07:43 PM

Hi, I have a RadFilter that I am trying to add an expression to on the form load. The idea is that when someone clicks a hyperlink on a different page, they are redirected to a different page and the radfilter is set up for them with the data they clicked (in this specific case, it would Select Amends and put in the appropriate value.

I just want to mention that this code works exactly how I need it to when It is inside of a button click event on the page that gets redirected to.

The following is called in my page_load:

        pnlSearch.Visible = False
        pnlAdvanced.Visible = True

        Dim amendsByExpression = New RadFilterContainsFilterExpression("Amends")
        amendsByExpression.Value = Session("Search_Text")
        rfAdvancedSearch.RootGroup.AddExpression(amendsByExpression)
        rfAdvancedSearch.FireApplyCommand()

 

Why does the code above work when its encapsulated inside of a linkbutton click event, but not in the page load? How can I make it work in the Page Load?

2 Answers, 1 is accepted

Sort by
0
Kurtis
Top achievements
Rank 1
answered on 20 Jun 2016, 01:23 PM

Just for more information, my control on the aspx page looks like this:

<telerik:RadFilter ID="rfAdvancedSearch" runat="server" DataSourceControlID="dsBylaw" FilterContainerID="rgBylaw" SharedCalendarMinDate="1870-01-01" 
            Visible="True" DefaultFieldEditorFieldName="Title" 
            Localization-FilterFunctionIsNull="" 
            Localization-FilterFunctionNotIsNull="" 
            Localization-FilterFunctionIsEmpty="" 
            Localization-FilterFunctionNotIsEmpty=""
            Localization-FilterFunctionLessThanOrEqualTo="Less Than Or Equal To" 
            Localization-FilterFunctionGreaterThanOrEqualTo="Greater Than Or Equal To" 
            Localization-FilterFunctionGreaterThan="Greater Than" 
            Localization-FilterFunctionEqualTo="Equal To" 
            Localization-FilterFunctionEndsWith="" 
            Localization-FilterFunctionLessThan="Less Than" 
            Localization-FilterFunctionStartsWith=""
            Localization-FilterFunctionDoesNotContain="" 
            Localization-FilterFunctionNotBetween="" 
            Localization-FilterFunctionNotEqualTo="">
        </telerik:RadFilter>

 

 

0
Eyup
Telerik team
answered on 22 Jun 2016, 08:47 AM
Hi Kurtis,

You can check the following live sample:
http://demos.telerik.com/aspnet-ajax/filter/examples/field-editors/defaultcs.aspx

Alternatively, you can try to do that on a different stage of the page life cycle, for example PreRender.

Regards,
Eyup
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
Filter
Asked by
Kurtis
Top achievements
Rank 1
Answers by
Kurtis
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or