ASP-NET - Grid Filtering

This article shows how to filter ASP.NET grids                       

Related Articles

... and you 'll find more on the Telerik ASPNET Grid Menu

In the header, add AllowFilteringByColumns, add the GroupSettings node so the filtering will not be case sensitive. Add AutoPostPackOnFilter for each column

 

<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False"  AllowFilteringByColumn="true"
    CssClass="grid" PageSize="50" AllowPaging="true"
    Width="100%" ShowFooter="false" CellSpacing="0" CellPadding="0" GridLines="None">
    <GroupingSettings CaseSensitive="false" />
    <MasterTableView DataKeyNames="custnmbr" ShowGroupFooter="false">
        <Columns>
            <telerik:GridButtonColumn ButtonType="LinkButton" Text="select" ItemStyle-Width="80px" ></telerik:GridButtonColumn>
            <telerik:GridBoundColumn DataField="custnmbr" HeaderText="Customer Number" ItemStyle-Width="80px" AutoPostBackOnFilter="true" ReadOnly="True"></telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="custname" HeaderText="Customer Name" AutoPostBackOnFilter="true" ReadOnly="True"></telerik:GridBoundColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

 This code will provide an 'empty message'

If TypeOf e.Item Is GridFilteringItem Then
    Dim filter As GridFilteringItem = DirectCast(e.Item, GridFilteringItem)
    For Each col As GridColumn In RadGrid1.MasterTableView.RenderColumns
 
        If col.OrderIndex > 1 AndAlso col.ColumnType = "GridBoundColumn" Then
            Dim txtbx As TextBox = TryCast(filter(col.UniqueName).Controls(0), TextBox)
            If txtbx.Text = "" Then
                txtbx.Text = "Filter text"
            End If
        End If
    Next
End If
 

 


RealWorldCode gives developers practical, real‑world solutions with clean, working code — no fluff, no theory, just answers.
Links
Home
Knowledge Areas
Sitemap
Contact
Et cetera
Privacy Policy
Terms and Conditions
Cookie Preferences