所以我在 sql 2008 服务器上有一个 Customers 表,我将它绑定到我的应用程序中的 gridview。搜索按钮使用以下代码重新绑定表:
ControlParameter ctrlParam = new ControlParameter();
ctrlParam.ControlID = "SearchTextBox";
ctrlParam.PropertyName = "Text";
ctrlParam.Name = "Search";
QueryStringParameter ctrlParam2 = new QueryStringParameter();
ctrlParam2.DefaultValue = "Canceled";
ctrlParam2.QueryStringField = "Canceled";
ctrlParam2.Name = "CustomerStatus";
ctrlParam2.Type = TypeCode.String;
SqlDataSource1.SelectParameters.Clear();
SqlDataSource1.SelectParameters.Add(ctrlParam);
SqlDataSource1.SelectParameters.Add(ctrlParam2);
SqlDataSource1.SelectCommand = "SELECT FullText_for_Customers.RANK, [CustomerId], [CustomerStatus], [CustomerGroup], [CustomerFirstName], [CustomerLastName], [CustomerFullName], [CompanyName], [CustomerAddress], [CustomerCity], [CustomerState], [CustomerZipcode], [CustomerFullAddress], [CustomerEmail], [CustomerEmail2], [CustomerPhoneNumber], [CustomerPhoneNumberExt], [CustomerType], [CustomerSubscriptionType], [CustomerCost], [CustomerPaymentMethod], [CustomerPickUpDay], [CustomerPickUpDay2], [CustomerSignUpDate], [CustomerNotes], [CustomerDriver] FROM [Customers] INNER JOIN FREETEXTTABLE(Customers, (CustomerFirstName, CustomerLastName, CustomerFullName, CompanyName, CustomerAddress, CustomerCity, CustomerState, CustomerZipcode, CustomerFullAddress, CustomerEmail, CustomerEmail2, CustomerPhoneNumber, CustomerNotes), @Search) as FullText_for_Customers ON FullText_for_Customers.[KEY]=Customers.CustomerId WHERE ([CustomerStatus] <> @CustomerStatus) ORDER BY FullText_for_Customers.RANK DESC";
现在当GridView
被拆分为CustomerID, CustomerFirstName, CustomerLastName, CustomerPickUpDay, and CustomerSignUpDate
.
当我搜索时,我只搜索名字,但我必须输入完整的名字或姓氏,我不能只输入一部分;比如取我的姓,Bonilla,我必须搜索 Bonilla 才能显示结果,我不能只搜索 Bon 或 Bo 或 illa。我怎么会有这份工作?