I am using Grid control to display some data. All columns use filter option. If the column has text data then all filter options are displayed.
I am getting error while filtering on text data column on "IsEmpty" and "IsNull" options. Whenever I click on IsEmpty button on filter menu I get the error as "
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
"I debugged and found that this error comes when the command name is "Filter" in Item_Command event while on e.CommandName expression. Please guide me on this issue. Its very urgent.
The names of menus shown in FilterMenu are like "EndsWith", "StartsWith". I need to add a blank space between words of filter menu like "Ends With". Please give me code on how do I do this.
Also, the I want to edit the filter menu only for some columns like for text columns I do not want to show "GreaterThan", "LessThan","Between" filters and keep them for numeric columns in same grid. Please guide me on how this can be done.
Thank you.
Prajakta A.
5 Answers, 1 is accepted

Try setting EnableLinqExpressioins property of grid as false and check whether this eliminates this exception.
Thanks,
Princy.

I tried setting the EnableLinqExpressioins="false". But its not working.
Can you suggest any other solution.
Thanks.
Prajakta A.
Can you specify what type of data you are trying to enter. Also it will be helpful you could post the RadGrid declaration so we can have a better idea on how it is configured.
On your other questions:
You can change the text for the filter menu items as shown here:
http://www.telerik.com/help/aspnet-ajax/grid-localizing-filtering-menu-options.html
You can also reduce the filter menu options as specified in this help topic:
http://www.telerik.com/help/aspnet-ajax/grid-reducing-filtermenu-options.html
Hope this helps.
Marin
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

<
telerik:RadGrid
ID
=
"radGridReferences"
runat
=
"server"
AutoGenerateColumns="False"
CommandItemDisplay="Top"
GridLines="Both"
AllowFilteringByColumn="True"
AllowSorting="true"
Width="100%"
AllowPaging="true"
PageSize="15"
OnNeedDataSource="RadGridReferences_NeedDataSource"
OnItemDataBound="RadGridReferences_OnItemDataBound"
OnItemCommand="RadGridReferences_OnItemCommand"
AllowMultiRowSelection="false"
ClientSettings-Resizing-AllowColumnResize="true"
EnableLinqExpressions="false"
ondatabound="radGridReferences_DataBound" >
<
MasterTableView
AutoGenerateColumns
=
"false"
CommandItemDisplay
=
"Top"
EditMode
=
"EditForms"
DataKeyNames
=
"ReferencesID"
AllowFilteringByColumn
=
"True"
TableLayout
=
"Auto"
Width
=
"100%"
NoDetailRecordsText
=
"No Records found"
NoMasterRecordsText
=
"No records found"
>
<RowIndicatorColumn>
<HeaderStyle Width="20px" />
</RowIndicatorColumn>
<ExpandCollapseColumn Visible="false">
<HeaderStyle Width="20px" />
</ExpandCollapseColumn>
<Columns>
<telerik:GridEditCommandColumn ButtonType="ImageButton" HeaderStyle-Width="10px" UniqueName="ReferencessEditButton">
<ItemStyle Width="2%" />
</telerik:GridEditCommandColumn>
<telerik:GridTemplateColumn AllowFiltering="false" HeaderStyle-Width="25px">
<ItemTemplate>
<asp:ImageButton ID="btnDelete" runat="server" CommandName="Delete" ImageUrl="~/Images/delete.gif" OnClientClick="javascript:return confirm('Are you sure you want to delete this record?')" />
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn Visible="false" FilterControlWidth="80px" DataField="ReferencesID" HeaderText="Reference ID" SortExpression="ReferencesID" UniqueName="ReferencesIDColumn" AllowFiltering="true">
<ItemTemplate>
<asp:Label ID="labelReferencesID" runat="server" Text='<%# Bind("ReferencesID") %>'></asp:Label>
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
<EditFormsettings editformtype="Template">
<FormTemplate>
<table>
<tr>
<td>
<mst:ReferencesInfo ID="uctrlReferencesInfo" runat="server" />
</td>
</tr>
<tr>
<td>
<asp:Button ID="btnUpdate" runat="server" CommandName="Update" Text="Submit" OnClientClick="return CheckFileNameExists();" /><%--OnClientClick="CheckFileNameExists(<%# Eval('uctrlReferencesInfo').FindControl('FileUpload') %>)"--%>
 
<asp:Button ID="btnCancel" runat="server" CommandName="Cancel" Text="Cancel" CausesValidation="false" />
</td>
</tr>
</table>
</FormTemplate>
</EditFormsettings>
<NestedViewTemplate>
<table>
<tr>
<td>
<mst:ReferencesInfo ID="uctrlReferencesInfo" runat="server" />
</td>
</tr>
</table>
</NestedViewTemplate>
</MasterTableView>
<ValidationSettings CommandsToValidate="PerformInsert,Update" EnableValidation="true" />
<ClientSettings AllowDragToGroup="True" EnablePostBackOnRowClick ="True">
<Scrolling AllowScroll="false" UseStaticHeaders="True" />
<Selecting AllowRowSelect="true" />
<Resizing AllowColumnResize="True" />
</ClientSettings>
<FilterMenu EnableTheming="True" Skin="Default2006" >
<CollapseAnimation Duration="200" Type="OutQuint" />
</FilterMenu>
<GroupingSettings CaseSensitive="false" />
<PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
<HeaderStyle HorizontalAlign="Left" />
</telerik:RadGrid>
I am getting the
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
error after clicking on IsEmpty filter menu of any column.
Please tell me some way to resolve this.
The default filter options for the GridTemplateColumn do not include the IsEmpty function. I checked with IsNull and it was working fine on my end. If you want to use additional functions for the TemplateColumn you can add them to the Filter menu and then handle them and apply custom logic to execute the filtering as shown in this and this help topics. Otherwise IsEmpty is should not appear on TemplateColumns.
Best wishes,Marin
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.