我正在尝试过滤gridview以显示特定日期之间的订单。我设法让它工作,但它没有显示Date To的记录。它只显示那些日期之间。日期中存在的记录显示...
<asp:EntityDataSource ID="EDS_Orders" runat="server" EnableUpdate="true" EnableFlattening="False" OrderBy="it.Order_date ASC"
ConnectionString="name=Bohemian1Entities" DefaultContainerName="Bohemian1Entities" EntitySetName="t_customer_orders"
Where="it.UserName is not null and (it.Order_date Between @DateFrom AND @DateTo) AND (it.UserName Like '%' + @UserName + '%') " >
<WhereParameters>
<asp:ControlParameter ControlID="ddlDateFrom" Name="DateFrom"
Type="DateTime" DefaultValue="%"/>
<asp:ControlParameter ControlID="ddlDateTo" Name="DateTo"
Type="DateTime" DefaultValue="%"/>
<asp:ControlParameter ControlID="ddlCustomers" Name="UserName" PropertyName="Text"
Type="String" DefaultValue="%"/>
</WhereParameters>
</asp:EntityDataSource>
答案 0 :(得分:0)
尝试重写Where
子句,如下所示:
Where="it.UserName is not null and (CAST(it.Order_date AS DATE) Between @DateFrom AND @DateTo)
AND (it.UserName Like '%' + @UserName + '%')"