使用objectdatasource搜索gridview

时间:2014-06-29 19:20:21

标签: asp.net

我有执行搜索的程序:

ALTER PROCEDURE dbo.book_serchbook
   @BookTitle nvarchar(100) ,
   @CategoryName nvarchar (100) ,
   @AuthorName nvarchar(100),
   @PublisherName nvarchar(100) 
AS
    SELECT DISTINCT 
       dbo.BookTable.BookID,
       dbo.BookTable.BookCover,
       dbo.BookTable.BookPrice,
       dbo.BookTable.BookTitle,
       dbo.PublisherTable.PublisherName,
       dbo.CategoryTable.CategoryName
    FROM          
       BookTable 
    INNER JOIN
       CategoryTable ON CategoryTable.CategoryID = BookTable.CategoryID
    INNER JOIN 
       PublisherTable ON PublisherTable.PublisherID = BookTable.PublisherID 
    LEFT OUTER JOIN
       BookAuthorTable 
    INNER JOIN 
       AuthorTable ON AuthorTable.AuthorID = BookAuthorTable.AuthorID 
       ON BookTable.BookID = BookAuthorTable.BookID
    WHERE     
       (PublisherTable.PublisherName LIKE '%' + @PublisherName + '%') and
       (BookTable.BookTitle LIKE '%' + @BookTitle + '%') and
       (AuthorTable.AuthorFName + ' ' + AuthorTable.AuthorLName LIKE '%' + @AuthorName + '%') and
       (CategoryTable.CategoryName= @CategoryName )

在我的ASPX页面上,我使用带有ObjectDataSource的gridview来显示结果,对象源代码是:

<asp:ObjectDataSource ID="ObjectDataSource4" runat="server" 
     DataObjectTypeName="BookDataBaseComponent.BookDetails"  OldValuesParameterFormatString="original_{0}"
     DeleteMethod="DeleteBook" InsertMethod="InsertBook" SelectMethod="SearchBook" 
     TypeName="BookDataBaseComponent.BookDB" UpdateMethod="UpdateBook">
     <DeleteParameters>
         <asp:Parameter Name="BookID" Type="Int32" />
     </DeleteParameters>
     <SelectParameters>
         <asp:ControlParameter ControlID="booktb" DefaultValue="%" Name="BookTitle" 
             PropertyName="Text" Type="String" />
         <asp:ControlParameter ControlID="DropDownList1" DefaultValue="%" 
             Name="CategoryName" PropertyName="SelectedValue" Type="String" />
         <asp:ControlParameter ControlID="afnbk" DefaultValue="%" Name="AuthorName" 
             PropertyName="Text" Type="String" />
         <asp:ControlParameter ControlID="pubtb" DefaultValue="%" Name="PublisherName" 
             PropertyName="Text" Type="String" />
     </SelectParameters>
 </asp:ObjectDataSource>

我的问题:当where子句中的条件与运算符存在时,页面不显示任何结果。当我将其更改为OR时,它会显示结果

当我点击搜索按钮没有任何反应时,我无法搜索。

请帮助。我真的需要帮助

0 个答案:

没有答案