1

我正在尝试过滤网格视图以显示特定日期之间的订单。我设法让它工作,但它没有显示日期的记录。它只显示这些日期之间的时间。Date from 中存在的记录显示...

 <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>
4

1 回答 1

0

尝试重写Where子句如下:

Where="it.UserName is not null and (CAST(it.Order_date AS DATE) Between @DateFrom AND @DateTo) 
    AND (it.UserName Like '%' + @UserName + '%')"
于 2013-03-29T18:51:30.667 回答