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

[Solved] Grid Filter Error

0 Answers 15 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
David
Top achievements
Rank 1
David asked on 08 Feb 2012, 05:19 PM
Hi,

I have a Telerik MVC Grid, which is bound to a SQL Server 2005 data source through a LINQ to SQL model. It is filterable. When I filter any of the columns of data type "char(1)" by putting in more than one character the program crashes. But if I filter any of the columns with char's more than 1, like "char(4)" and I put in 8 characters, the program handles the error and just displays no records.

The error I get is:
FormatException was unhandled by user code
Sting must be exactly one character long.

Here is my Grid from the View:

@(Html.Telerik().Grid((IEnumerable<SYSTEM_OVERVIEW>)ViewBag.Overview)
        .Name("Overview")
    .ToolBar(commands => commands
            .Custom()
            .HtmlAttributes(new { id = "btnExportSelected" })
                .Text("Export Selected")
                .Action("Export_Selected", "Home", new { orderByOverview = "~", filterOverview = "~", orderByWith_Keys = "~", filterWith_Keys = "~" }))
    .ToolBar(commands => commands
            .Custom()
            .HtmlAttributes(new { id = "btnExportAll" })
                .Text("Export All")
                .Action("Export_All", "Home", new { orderByOverview = "~", filterOverview = "~", orderByWith_Keys = "~", filterWith_Keys = "~" }))
    .Columns(columns =>
        {
            columns.Bound(c => c.ColumnA).Width(140);
       
columns.Bound(c => c.ColumnB).Width(140);
            columns.Bound(c => c.ColumnC).Width(140);
            columns.Bound(c => c.ColumnD).Width(140);
        })
        .DataBinding(dataBinding => dataBinding.Ajax().Select("Overview", "Home"))
    .Pageable()
    .Sortable()
    .Selectable()
    .Filterable()
    .Scrollable()
    .Resizable(resizing => resizing.Columns(true))
    .ClientEvents(events => events.OnRowSelect("onRowSelected"))
    .ClientEvents(clientEvents => clientEvents.OnDataBound("onDataBoundOverview"))
    .RowAction(row => row.Selected = row.DataItem.TRAIN_ID_REC.Equals(ViewBag.T_ID))
    .RowAction(row => row.Selected = row.DataItem.STATION_ID.Equals(ViewBag.S_ID))
  )

Thanks
Tags
Grid
Asked by
David
Top achievements
Rank 1
Share this question
or