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

[Solved] Filter expression LIKE operator

5 Answers 437 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Prabhu
Top achievements
Rank 2
Prabhu asked on 02 Sep 2009, 10:04 AM
Hi,

            Im having Gird, Textbox and a search button in the form. User has to enter the value into the textbox and upon clicking the button, ive to show the records that matches the text from textbox in Radgrid. I've used the following code to accomplish the task.

protected

 

void imgSearch_Click(object sender, EventArgs e)

 

{

    Grd1.EnableLinqExpressions =

false;

 

 

    string l_filer = string.Empty;

 

 

    if (!String.IsNullOrEmpty(txtName.Text.Trim()))

 

        l_filer =

"name LIKE '" + txtName.Text.Trim() + "'";

 

 

    else

 

        l_filer =

"1 = 1 ";

 

    GrdUDF.MasterTableView.FilterExpression =

"(" + l_filer + ")";

 

    GrdUDF.Rebind();

}

Here the problem is, when I give the exact word in the textbox, it will give me the result. but I want to search the records using "Contains". say for example, If I'm giving "D" in textbox, it should show the list of records, that contains "D". if nothing I there, then I've to show all the records in the grid.

I dont know, where I slipped. any help????
thanks in advance,
Prabhu KS

5 Answers, 1 is accepted

Sort by
0
Prabhu
Top achievements
Rank 2
answered on 02 Sep 2009, 10:57 AM

 

Hai,
    I solved above issue. its pretty simple. I found help from one of the forum. now, I want to do same search in hierarchical grid. if the text in the texbox matches with any of the detail table record, then we have to show parent records. on expanding the parent item, i will fetch the detail values from DB(HierarchyLoadMode="ServerBind"). Is that possible???


any help appreciated,
Thanks in advance,
Prabhu KS


0
Prabhu
Top achievements
Rank 2
answered on 02 Sep 2009, 12:00 PM
Hi,

    I face a new problem; I want to search the records using FilterExpression; but it searches records with case sensitive. for example, if I give 'd', it will give list of records that contains 'd' (small) not 'D'(Caps). But I want that too... When the user gives that letter or word, it should search the records in all the cases

Thanks
Prabhu KS 
0
Casey
Top achievements
Rank 1
answered on 02 Sep 2009, 12:02 PM
Prabhu,

It makes sense that the LIKE would only return values when they matched exactly because there were no wildcard characters, so it was searching for the exact value entered. I'm not sure if adding wildcard characters around the following is how the issue was solved or not, but I'd be interested to find out how you were able to resolve it.

l_filer = "name LIKE '%" + txtName.Text.Trim() + "%'"; // not sure if % is the wildcard for RadGrid.

Casey
0
Accepted
Casey
Top achievements
Rank 1
answered on 02 Sep 2009, 12:08 PM
Hi Prabhu,

To make the filter be case insensitive in a RadGrid change the CaseSensitive property from "True" to "False" in the GroupSettings area.

Casey

<

 

GroupingSettings CaseSensitive="False" />

 

0
Prabhu
Top achievements
Rank 2
answered on 02 Sep 2009, 02:12 PM
Casey,

    By using <GroupingSettings CaseSensitive="False" />, I've solved that issue. Thanks a lot... I want to do same search in hierarchical grid. if the text in the texbox matches with any of the detail table record, then we have to show parent records. on expanding the parent item, i will fetch the detail values from DB (HierarchyLoadMode="ServerBind"). Is that possible???

FYI, I got solution from here...
http://www.telerik.com/community/forums/aspnet-ajax/grid/filtertemplate-filter-value-remains-quot-all-quot.aspx
Tags
Grid
Asked by
Prabhu
Top achievements
Rank 2
Answers by
Prabhu
Top achievements
Rank 2
Casey
Top achievements
Rank 1
Share this question
or