I am using the built-in filtering on a RadGrid but I'm running into a problem with one column in particular. When I try to filter on the column in question, I get an "Object reference not set to an instance of an object" error and the filtering doesn't work. This particular column is generated from a subquery that's being used as a column expression (and then given an alias). It seems like the filtering only works for grid columns that have a matching column name in a database table (i.e. doesn't seem to work with columns generated from a subquery or UDF). Here is my aspx markup:
<telerik:RadGrid ID="grdAdmin" runat="server" Width="100%" AllowFilteringByColumn="True"
GridLines="None" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" onneeddatasource="grdAdmin_NeedDataSource"
PageSize="20"
ondeletecommand="grdAdmin_DeleteCommand">
<GroupingSettings CaseSensitive="false" />
<MasterTableView DataKeyNames="NominationID" NoMasterRecordsText="There are currently no nominations to display."
Width="100%" CommandItemDisplay="Top" AutoGenerateColumns="False">
<Columns>
<telerik:GridDateTimeColumn DataField="DateOfNomination" DataFormatString="{0:d}" HeaderText="Date Of Nomination" SortExpression="DateOfNomination" UniqueName="DateOfNomination" ReadOnly="true">
</telerik:GridDateTimeColumn>
<telerik:GridBoundColumn DataField="NomineeName" HeaderText="Nominee Name"
SortExpression="NomineeName" DataType="System.String" UniqueName="NomineeName" ReadOnly="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="NominatorName" HeaderText="Nominator Name"
SortExpression="NominatorName" DataType="System.String" UniqueName="NominatorName" ReadOnly="true" AllowFiltering="false">
</telerik:GridBoundColumn>
<telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="DeleteCommandColumn" ConfirmDialogType="Classic" ConfirmText="Are you sure you want to delete this nomination from the database?" ConfirmTitle="Are you sure?">
</telerik:GridButtonColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
The column that I get the error on is the NomineeName column. Here is the C# codebehind:
And here is the NominationAdmin.cs file:
Any idea what's going on and how to fix it? Thanks.