SessionIDs ids = (SessionIDs)Session["IDs"];
BSDataContext ct = new BSDataContext();
var customers = from cust in ct.tblCustomers
where cust.AccountID == ids.accountID && drpFilter.SelectedValue.StartsWith(txtSearch.Text.ToString())
join mem in ct.tblCustomerMemberships on cust.CustomerID equals mem.CustomerID
select new { cust.CustomerID, cust.Mobile, cust.BusinessPhone, cust.Code, cust.Email, cust.HomePhone, mem.Membership, Name = cust.FirstName + cust.LastName };
grdCustomer.DataSource = customers;
grdCustomer.DataBind();
我的记录以Waqar
开头,但没有显示。
drpFilter.SelectedValue = cust.Name and txtSearch.Text = Waqar
请帮助我
答案 0 :(得分:2)
我可以看到一个问题:
SessionIDs ids = (SessionIDs)Session["IDs"];
BSDataContext ct = new BSDataContext();
var customers = from cust in ct.tblCustomers
where cust.AccountID == ids.accountID &&
drpFilter.SelectedValue.StartsWith(txtSearch.Text.ToString()) //<-- HERE
join mem in ct.tblCustomerMemberships
on cust.CustomerID equals mem.CustomerID
select new { ... };
如果执行此操作:drpFilter.SelectedValue.StartsWith(txtSearch.Text.ToString())
它只会给你一个布尔值
因此,生成的SQL看起来像这样:
WHERE AccountID = @p1 AND TRUE