If you want to set an initial filter on a Telerik RadGrid, use the “NeedDataSource” event and set the MasterTableView.FilterExpression and use the function MasterTableView.GetColumnSafe

        protected void RadGrid_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
        {
            // Set datasource here…
            
            if (!IsPostBack)
            {
                // Set initial filter on [RadGrid]
                this.RadGrid.MasterTableView.FilterExpression = string.Format("([Date] = '{0}')", DateTime.Today);

                // Set current filter function and value on [Date]
                GridColumn column = this.RadGrid.MasterTableView.GetColumnSafe("Date");
                column.CurrentFilterFunction = GridKnownFunction.EqualTo;
                column.CurrentFilterValue = DateTime.Today.ToString();
            }
        }

In the aspx page use “EqualTo” as filter, not “Contains” and use a GridDateTimeColumn not a GridBoundColumn

              <telerik:GridDateTimeColumn
                   DataField="Date"
                   HeaderText="Date"
                   SortExpression="Date"
                   UniqueName="Date"
                   FilterControlWidth="70px"
                   ShowFilterIcon="false"
                   DataType="System.DateTime"
                   CurrentFilterFunction="EqualTo"
                   PickerType="DatePicker"
                   AutoPostBackOnFilter="true"
                   HtmlEncode="false"
                   DataFormatString="{0:dd-MM-yyyy}"
                   meta:resourcekey="Date">
                   <ItemStyle Width="70px" />
               </telerik:GridDateTimeColumn>

3 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.