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

RadGrid filtering doesn't work

1 Answer 117 Views
Grid
This is a migrated thread and some comments may be shown as answers.
nav100
Top achievements
Rank 1
nav100 asked on 22 Nov 2011, 10:44 PM
Hello,

The RadGrid filtering doesn't work. The RadGrid is empty shows empty when I filter by last name. Could you please let me know what could be the problem? Thanks for any help. Her is my code.

<telerik:RadGrid ID="RadGrid1" AutoGenerateColumns="False" 
                AlternatingItemStyle-HorizontalAlign="Left" FilterItemStyle-HorizontalAlign="Left"
                HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Left" Width="101%"
                runat="server" AllowPaging="True" GridLines="None" AllowFilteringByColumn="true"
                ShowFooter="True" ShowStatusBar="True" OnItemCommand="Add" AllowSorting="true"
                    
                <GroupingSettings CaseSensitive="false" /> 
<HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default"></HeaderContextMenu
    
                <AlternatingItemStyle BackColor="gainsboro" /> 
                <MasterTableView PageSize="50"
                    <PagerStyle Mode="NextPrevNumericAndAdvanced"></PagerStyle
                    <Columns
                            <telerik:GridBoundColumn DataField="test_id" UniqueName="test_id" 
                           HeaderText="Test ID" Display="false"/> 
                        <telerik:GridBoundColumn DataField="last_name" UniqueName="last_name" 
                            FilterControlAltText="Filter last_name column" HeaderText="Name" 
                            SortExpression="last_name"/> 
                        <telerik:GridButtonColumn CommandName="TestSelected" 
                            FilterControlAltText="Filter column column" Text="Add" 
                            UniqueName="column"
                        </telerik:GridButtonColumn
                    </Columns
                </MasterTableView
                <ClientSettings
                    <Selecting AllowRowSelect="True"  /> 
                </ClientSettings
                <FilterMenu EnableTheming="True" Skin="Default"
                    <CollapseAnimation Duration="200" Type="OutQuint" /> 
                </FilterMenu
                <AlternatingItemStyle HorizontalAlign="Left" /> 
                <ItemStyle HorizontalAlign="Left" /> 
                <HeaderStyle HorizontalAlign="Center" /> 
                <FilterItemStyle HorizontalAlign="Center" /> 
            </telerik:RadGrid>

Code behind

protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        if (this.Request.QueryString["name"] != string.Empty)
        {
            string sqlstr = "SELECT * from tableName where last_name = '" + this.Request.QueryString["name"] + "') ";
            RadGrid1.DataSource = GetDataTable(sqlstr);
            RadGrid1.DataBind();
            RadGrid1.Visible = true;
        }
    }
    else
    {
            RadGrid1.DataSource = null;
            RadGrid1.Rebind();
            RadGrid1.Visible = true;
        }
    }
}

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 23 Nov 2011, 04:58 AM
Hello,

In order to implement advanced features in RadGrid like paging, filtering, grouping etc, you should bind the grid with Advanced data binding using its NeedDataSource event. Check the following help documentation which explains more about this.
Advanced Data-binding (using NeedDataSource event)

-Shinu.
Tags
Grid
Asked by
nav100
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or