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

[Solved] RadGrid Filter expression with ";" i.e with semicolon is throwing Index was outside the bounds of the array

3 Answers 216 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sreenivas
Top achievements
Rank 1
Sreenivas asked on 18 Sep 2009, 02:49 PM
Hi,

Simple grid with one template column and enabled filter. If we input semicolon ';' in the filtertextbox and do filter by "equal" it throws out of bounds exception. This errors occors on the demo grids also.
For example: click on the below link
http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/filtering/defaultcs.aspx

Input some thing with semicolon on "ShipName" column, example.. Vins; and do a tabout it throws error.

ASPX code:

<

 

telerik:RadGrid ID="myRadGrid" runat="server" OnItemDataBound="myRadGrid_ItemDataBound">

 

 

    <MasterTableView AllowFilteringByColumn="true">

 

 

   <Columns>

 

 

      <telerik:GridTemplateColumn DataField="Name" HeaderText="Name" AutoPostBackOnFilter="true"

 

 

         AllowFiltering="true">

 

 

      </telerik:GridTemplateColumn>

 

 

   </Columns>

 

 

  </MasterTableView>

 

 

</telerik:RadGrid>

cs code:

 

List

 

<string> s = new List<string> {"sreeni","ravi"};

 

myRadGrid.DataSource = s;

myRadGrid.DataBind();


This is kind of a production bug for us. Please let us know the solution as soon as possible.

Thanks
Sreenivas.
KPMG Montvale, NJ

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 22 Sep 2009, 11:03 AM
Hi sreenivas,

One suggestion would be preventing the entry of : in filter textbox. Have a look at the following code which shows how to accomplish this.

CS:
 
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)  
{  
    if (e.Item is GridFilteringItem)  
    {  
        GridFilteringItem fItem = (GridFilteringItem)e.Item;  
        foreach (GridColumn col in RadGrid1.MasterTableView.Columns)  
        {  
            (fItem[col.UniqueName].Controls[0] as TextBox).Attributes.Add("onkeyup""CheckChar(this, event)");  
        }  
    }  

JavaScript:
 
<script type="text/javascript"
function CheckChar(text,e) 
  var regx, flg;   
    regx = /[:]/   
    flg = regx.test(text.value);   
    if (flg) 
    {   
        var val=text.value; 
        val=val.substr(0,(val.length)-1) 
        text.value=val;       
    } 
</script> 

-Shinu.
0
Steven Randlett
Top achievements
Rank 1
answered on 10 Nov 2009, 06:05 PM
If data in a field has 'and' in it the filter will do nothing.  It doesn't return an error but it does not filter. Has anyone else experienced this.  Any suggestions?
0
Mira
Telerik team
answered on 11 Nov 2009, 09:56 AM
Hello Sreenivas,

AND is an reserved word in the SQL language and the RadGrid automatically stripes all logical operation in the filter box to prevent malicious input. To implement the desired by you functionality you need to use custom filtering.

Regards,
Mira
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Sreenivas
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Steven Randlett
Top achievements
Rank 1
Mira
Telerik team
Share this question
or