Click here to Skip to main content
15,881,380 members
Please Sign up or sign in to vote.
4.50/5 (2 votes)
See more:
Hi,
My form having one textbox,one ajax calendar extender, one search button and two radio buttons using linq. if i enter name or designation and so on in textbox and i click search button it will display the corresponding data in the gridview from database using linq like operator. it is working correctly(it shows hthe results in gr) my problem is when i click the calendar control and select the date that will be displayed in textbox then i click the search button it doesn't shows any results
my error is linq search doesn't supports datetime directly.

my code is here:
C#
       protected void btnSearch_Click(object sender, EventArgs e)
        {
                if (RbnRelieve.Checked == true)
                {
                    //RbnTerminate.Checked = false;
                    string searchstr = TxtSearch.Text;
                    string likstr = searchstr + "%";
                    var search = (from a in db.M_TblAttritions where SqlMethods.Like(a.EmployeeID, likstr) || SqlMethods.Like(a.EmployeeName, likstr) || SqlMethods.Like(a.Designation, likstr) || SqlMethods.Like(a.ApprovedBy, likstr) || SqlMethods.Like(a.NoticePeriod,likstr)||SqlMethods.Like(a.RelievingDate,likstr)select a);
                   
  if (search != null)
  {
       GridView1.DataSource = search;
       GridView1.DataBind();
  }
}
}

how to display date in gridview from database using linqsearch like operator in asp.net
Posted
Updated 25-Jun-12 2:06am
v2

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900