RadTextBox text after rebind

2 posts, 0 answers
  1. Fenris
    Fenris avatar
    4 posts
    Member since:
    Feb 2015

    Posted 18 Feb 2015 Link to this post

    My Grid has a RadTextBox that is being used to filter on all the columns. It Looks like this:

    <telerik:RadGrid runat="server" ID="grid1" GridLines="None" ShowFooter="False" Culture="de-DE">
        <MasterTableView AutoGenerateColumns="False" AllowMultiColumnSorting="True" CommandItemDisplay="Top">
                <telerik:RadToolBar ID="radToolBar" Skin="Windows7" runat="server" AutoPostBack="true" Width="100%">
                        <telerik:RadToolBarButton Value="section2">
                                <telerik:RadTextBox ID="textbox1" runat="server" Skin="Windows7"><ClientEvents OnKeyPress="OnKeyPress" /></telerik:RadTextBox>
                                <telerik:RadButton ID="btnSearch" runat="server" Skin="Windows7" Text="Search" CommandName="Search" OnClick="searchButton_Click"/>
        <GroupingSettings CaseSensitive="False" />

    Now when I click the button to do the filtering, this function gets called.

    protected void searchButton_Click(object sender, EventArgs e)
        RadTextBox searchFilter = GetSearchBox();
        if (searchFilter == null) return;
        var filterExpression = new StringBuilder();
        var searchText = searchFilter.Text;
        foreach (GridColumn col in grid1.MasterTableView.Columns)
                filterExpression.Length != 0 ? " OR " : string.Empty, col.UniqueName, searchText);
        activePassiveGrid.MasterTableView.FilterExpression = filterExpression.ToString();

    This works as expected. But after the Rebind(), the filtering becomes active, which clears the text in my textbox. I don't want it to be cleared, so you can still see what your filter searches for. Is it somehow possible to keep the text in the textbox?

  2. Fenris
    Fenris avatar
    4 posts
    Member since:
    Feb 2015

    Posted 18 Feb 2015 in reply to Fenris Link to this post

    Got it working. After the Rebind() I had to retrieve the TextBox again and reset the text. et voila!
Back to Top