public void BindSearchGrid()
    {
        objBll = new WarringtonBll.WarringtonBll();
        SearchParam objSearchParam = new SearchParam()
        {
            UserId = Utility.GetSessionValue<string>(Constants._LOGINUSERID),
            RequestStatus = txtStatus.Text,
            RequestNo = txtRequestNo.Text,
            RequestDate = string.IsNullOrEmpty(txtRequestDate.Text) ? DateTime.MinValue :
            DateTime.ParseExact(txtRequestDate.Text, "MM/dd/yyyy", null),
            CompareOperator=ddlOperator.SelectedValue,
            NoOfData=Convert.ToInt32(ddlPageSize.SelectedValue)
        };
        List<UserRequest> lstRequest = objBll.SearchRequest(objSearchParam);
        DataTable dtSearchResult = new DataTable();
        dtSearchResult.Columns.Add("Request_No");
        dtSearchResult.Columns.Add("Request_ID");
        dtSearchResult.Columns.Add("Request_Date");
        dtSearchResult.Columns.Add("Request_ChangeDate");
        dtSearchResult.Columns.Add("Request_Status");
        dtSearchResult.Columns.Add("Request_Address");
        dtSearchResult.Columns.Add("Request_ShortDesc");
        dtSearchResult.Columns.Add("Request_LongDesc");

        foreach (UserRequest  objrequest in lstRequest)
        {
            DataRow drRequest = dtSearchResult.NewRow();
            drRequest["Request_No"] = objrequest.RequestNo;
            drRequest["Request_ID"] = objrequest.RequestId;
            drRequest["Request_Date"] = objrequest.CreateDate.Value.Date.ToShortDateString();
            drRequest["Request_ChangeDate"] = objrequest.UpdateDate!=null?objrequest.UpdateDate.Value.Date.ToShortDateString():null;
            drRequest["Request_Status"] = objrequest.Status.Trim().Equals("O")?"Open":"Closed";
            drRequest["Request_Address"] = objrequest.ProblemLocation;
            drRequest["Request_ShortDesc"] = objrequest.ShortDescription;
            drRequest["Request_LongDesc"] = objrequest.LongDescription;
            dtSearchResult.Rows.Add(drRequest);
        }
        dtSearchResult.AcceptChanges();
        grdRequests.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
        if (!dtSearchResult.DataTableIsEmpty())
        {
            Utility.SetSessionValue(Constants._SEARCHREQUESTDATA, dtSearchResult);
            grdRequests.DataSource = dtSearchResult;
            grdRequests.DataBind();
        }
        else
        {
            grdRequests.Dispose();
            grdRequests.DataBind();
        }
    }
 public List<UserRequest> SearchRequest(SearchParam objParam)
 {
     try
     {
         objDal = new WarringtonDal();
         return objDal.SearchRequest(objParam);
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         objDal = null;
     }
     return null;
 }
        public List<UserRequest> SearchRequest(SearchParam objParam)
        {
            List<UserRequest> lstRequests = new List<UserRequest>();
            using (var context = new TheThinkerz_WTPSharePointEntities())
            {
                try
                {
                    var result = context.tblUserRequests.Where(r => string.IsNullOrEmpty(objParam.RequestNo) ? (objParam.RequestNo.Equals(string.Empty)) : (r.RequestNo.Equals(objParam.RequestNo))
                        && (r.PrimaryPhoneNo.Equals(objParam.UserId))
                        && (string.IsNullOrEmpty(objParam.RequestStatus) ? (objParam.RequestStatus.Equals(string.Empty)) : (r.Status.Equals(objParam.RequestStatus)))
                        ).ToList<tblUserRequest>();
                    switch (objParam.CompareOperator)
                    {
                        case "=":
                            result = result.Where(p => (objParam.RequestDate == DateTime.MinValue ?
                                (objParam.RequestDate.Equals(DateTime.MinValue)) :
                                (DateTime.Compare(p.CreateDate.Value.Date, objParam.RequestDate.Date) == 0))).ToList<tblUserRequest>();
                            break;
                        case ">":
                            result = result.Where(p => (objParam.RequestDate == DateTime.MinValue ? (objParam.RequestDate.Equals(DateTime.MinValue)) :
                                (DateTime.Compare(p.CreateDate.Value.Date, objParam.RequestDate.Date) > 0))).ToList<tblUserRequest>();
                            break;
                        case "<":
                            result = result.Where(p => (objParam.RequestDate == DateTime.MinValue ?
                                (objParam.RequestDate.Equals(DateTime.MinValue)) :
                                (DateTime.Compare(p.CreateDate.Value.Date, objParam.RequestDate.Date) < 0))).ToList<tblUserRequest>();
                            break;
                    }
                    //result = result.Take(objParam.NoOfData).ToList<tblUserRequest>();
                    result = result.ToList<tblUserRequest>();

                    foreach (tblUserRequest objRequest in result)
                    {
                        lstRequests.Add(new UserRequest()
                        {
                            RequestId = objRequest.RequestId,
                            RequestNo = objRequest.RequestNo,
                            CreateDate = objRequest.CreateDate,
                            UpdateDate = objRequest.UpdateDate,
                            Status = objRequest.Status,
                            ProblemLocation = objRequest.ProblemLocation,
                            ShortDescription = objRequest.ShortDescription,
                            LongDescription = objRequest.LongDescription
                        });
                    }
                }
                catch (Exception)
                {

                    throw;
                }
            }
            return lstRequests;
        }