0

I tried bind a AspxGridView by LinqDataSource

But I get this error : LINQ to Entities' System.DateTime Parse (String) method, this method does not recognize and can not be converted into a store expression.

How can I set a where condition for lnqTransferOrder ?

     private void BindGrid()

     { 

      this.lnqTransferOrder.Where = "DateScheduled >= DateTime.Parse(\"" + this.dtTranferDateFirst.Date.ToString() + "\")&&DateScheduled < DateTime.Parse(\"" + this.dtLastDate.Date.ToString() + "\") && Statues!=5";


        gridTransferOrder.DataBind();

     }

Aspx

      <asp:LinqDataSource ID="lnqTransferOrder" 
      ContextTypeName="MyApp.MyAppEntities"  TableName="TransferOrder" 
       runat="server" ondeleting="lnqTransferOrder_Deleting"  
       OnInserting="lnqTransferOrder_Inserting" OnUpdating="lnqTransferOrder_Updating"
        Where="Statues==0" EntityTypeName="">
       </asp:LinqDataSource>
user3107343
  • 2,159
  • 6
  • 26
  • 37
  • 6
    Why are you trying to convert a `DateTime` to a string and back again? Just specify a parameter for the date, and specify the `DateTime` value for that parameter. Avoid string conversions wherever you can - they can cause all kinds of problems, and they obfuscate what you're *really* trying to do. – Jon Skeet Jun 12 '14 at 13:11
  • Possible duplicate of http://stackoverflow.com/questions/7740693/big-issue-in-converting-string-to-datetime-using-linq-to-entities – Mike Jun 12 '14 at 13:34

0 Answers0