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

[Solved] Problem in Custom Search using RadGrid

2 Answers 85 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rajiv Prashant
Top achievements
Rank 1
Rajiv Prashant asked on 03 Aug 2010, 08:39 AM
hi

Very urgent please help me


i have implemented custom search in itemCommed event in my grid. but i could not execute that its getting error in "Expression expected" i checked all the possibility but i could not correct it. At the same time i implemented grouping that grouping working fine there is no issue. But searching only i have problem. please check it and let me know as soon as possible
below i pasted my c# code as well as  asp.net code

c#

 protected void RadGridMsgInbox_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
    {
        e.Canceled = true;
        Button btnG = (Button)e.Item.FindControl("btnGeneral");
        Button btnI = (Button)e.Item.FindControl("btnGeneral");
        Button btnN = (Button)e.Item.FindControl("btnGeneral");
        switch (e.CommandName)
        {
                // THIS CASE FIRE WHEN GRID SEARCH EVENT ACCOUR
            case "SearchUsersBy":
                    TextBox txtSearch = (TextBox)e.Item.FindControl("txtSearch");
                    RadioButton rdbtnFrom = (RadioButton)e.Item.FindControl("rdbtnFrom");
                    RadioButton rdbtnSubject = (RadioButton)e.Item.FindControl("rdbtnSubject");
                    ObjCC_Msg.MsgSearchStr = "";
                    if (rdbtnFrom.Checked)
                        this.RadGridMsgInbox.MasterTableView.FilterExpression = "([SentEmail] LIKE '%" + txtSearch.Text + "%')";
                    else if(rdbtnSubject .Checked )
                        this.RadGridMsgInbox.MasterTableView.FilterExpression = "( [MessageSubject] LIKE '%" + txtSearch.Text + "%' )";
                    else
                        this.RadGridMsgInbox.MasterTableView.FilterExpression = "(([MessageSubject] LIKE '%" + txtSearch.Text + "%') OR ([SENTEMAIL] LIKE '%" + txtSearch.Text + "%'))";
                  
                    if (RTbMessageMenu.SelectedIndex == 1)
                      ObjCC_Msg.GetMessage = FromMessage.Sent;
                    
                    //RadGridMsgInbox.MasterTableView.GroupByExpressions.Clear();
                    //RadGridMsgInbox.MasterTableView.Rebind();
                    RadGridMsgInbox.Rebind();
               break;
}
}

ASP.NET Code

 <CommandItemTemplate>
                                                <table cellpadding="0" cellspacing="0" border="0" width="98%">
                                                    <tr>
                                                        <td style ="width :30%">
                                                            <table border="0" cellpadding="0" cellspacing="0" width ="100%">
                                                                <tr>
                                                                    <td style ="width :90%">
                                                                        <asp:TextBox ID="txtSearch" runat="server" Width ="90%"></asp:TextBox>&nbsp;</td>
                                                                    <td style ="width :10%">
                                                                        <asp:Button ID="lnkBtnSearch" CssClass="mainSearchBtn" runat="server" Text="" CommandName ="SearchUsersBy"></asp:Button>
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td colspan ="2">
                                                                        <asp:RadioButton ID="btnAll" runat ="server" Text ="All" GroupName ="Search" Checked ="true" />&nbsp;
                                                                        <asp:RadioButton ID="rdbtnFrom" runat ="server" Text ="From" GroupName ="Search" />&nbsp;
                                                                        <asp:RadioButton ID="rdbtnSubject" runat ="server" Text ="Subject" GroupName ="Search" />
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </CommandItemTemplate>

*Note: Here i attached my error screen please go through that

i am waiting for your reply

2 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 05 Aug 2010, 10:39 AM
Hello Rajiv,

Please try to set EnableLinqExpressions property of the grid to false and let me know if it helps to avoid this error.

All the best,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Rajiv Prashant
Top achievements
Rank 1
answered on 05 Aug 2010, 11:47 AM
Hai Pavlina

Thanks lot . now it working fine

Tags
Grid
Asked by
Rajiv Prashant
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Rajiv Prashant
Top achievements
Rank 1
Share this question
or