I work with an ASP.NET DevExpress v19 grid view. I face an issue when searching in the grid view column "Depart code".
It accepts a filter and searches by numbers, but text does not accept filter.
As an example, column "Depart Code" has a value of 101HRE
.
- If I search for
101
, I get a result value of101HRE
successfully. - If I search for
HRE
, I do not get a result – an empty result set is returned
Why does it accept search by numbers and not accept search by text on column "Depart Code"?
Full code details
<%@ Page Title="" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true" CodeBehind="SickLeaveDashboard.aspx.cs" Inherits="UCHRADMIN.SickLeaveDashboard" %>
<%@ Register Assembly="DevExpress.Web.v19.1, Version=19.1.16.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web" TagPrefix="dx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<dx:ASPxGridView ID="ASPxGridView1" Width="100%" runat="server" AutoGenerateColumns="False" SettingsExport-FileName="Leave Type DashBoard" DataSourceID="SqlDataSource1" KeyFieldName="ID" ClientInstanceName="grid" Theme="PlasticBlue" >
<SettingsPager PageSize="10">
</SettingsPager>
<SettingsExport EnableClientSideExportAPI="true"/>
<SettingsEditing EditFormColumnCount="1" Mode="PopupEditForm">
</SettingsEditing>
<Settings ShowFilterRow="True" ShowGroupPanel="True" />
<SettingsPopup>
<EditForm Modal="True" ShowShadow="True" VerticalAlign="WindowCenter" HorizontalAlign="WindowCenter">
</EditForm>
</SettingsPopup>
<Toolbars>
<dx:GridViewToolbar>
<SettingsAdaptivity Enabled="True" EnableCollapseRootItemsToIcons="True" />
<Items>
<dx:GridViewToolbarItem Command="ExportToXls" />
</Items>
</dx:GridViewToolbar>
</Toolbars>
<Columns>
<dx:GridViewDataTextColumn FieldName="Emp No" Visible="True" ReadOnly="True" VisibleIndex="1">
<EditFormSettings Visible="False" />
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="Emp Name" VisibleIndex="2" PropertiesTextEdit-ValidationSettings-RequiredField-IsRequired="true">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="Dept Code" VisibleIndex="3" PropertiesTextEdit-ValidationSettings-RequiredField-IsRequired="true">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="Dept Name" VisibleIndex="4" PropertiesTextEdit-ValidationSettings-RequiredField-IsRequired="true">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="With Attachment" VisibleIndex="5" PropertiesTextEdit-ValidationSettings-RequiredField-IsRequired="true">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="Without Attachment" VisibleIndex="6" PropertiesTextEdit-ValidationSettings-RequiredField-IsRequired="true">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="Year" VisibleIndex="7" PropertiesTextEdit-ValidationSettings-RequiredField-IsRequired="true">
</dx:GridViewDataTextColumn>
</Columns>
</dx:ASPxGridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
OldValuesParameterFormatString="original_{0}"
SelectCommand="SELECT
r.EmpNo AS [Emp No],
EmpName AS [Emp Name],
cast(REPLACE(REPLACE(m.DEPT, ' ', ''), CHAR(13)+CHAR(10), '') as varchar(100)) AS [Dept Code],
cast(b.MCDL01 as nvarchar(200)) AS [Dept Name],
SUM(CASE WHEN (r.AttachmentFileName IS NOT NULL) THEN 1 ELSE 0 END) AS [With Attachment],
SUM(CASE WHEN (r.AttachmentFileName = '' or r.AttachmentFileName IS NULL ) THEN 1 ELSE 0 END) AS [Without Attachment],
YEAR(r.FromDate) AS [Year]
into #y
FROM
[dbo].[tblRequest] r
INNER JOIN
[dbo].[vEmployeeMaster] m ON m.EMPNO = r.EmpNo
INNER JOIN
[dbo].[vBusinessUnitMaster] b ON MCMCU = m.DEPT
WHERE
r.RequestType IN ('SLP', 'SLH', 'SLU') --and m.DEPT like '%101%'
GROUP BY
r.EmpNo, EmpName, m.DEPT, YEAR(r.FromDate), b.MCDL01
ORDER BY r.EmpNo, EmpName
select * from #y" >
</asp:SqlDataSource>
</div>
</div>
</div>
</div>
</asp:Content>
This screenshot shows the issue:
2
Answers
This SelectCommand appears to incorrect. "–and"
Try searching for %HRE.
I haven’t use the aspx version of DevExpress, but I would suspect it would behave similar to the Winforms version where HRE is translated in a filter of Starts with
and %HRE is translated into a Contains