Download
Academy
Current location: Downcodes.com -> Academy -> Programming -> .NET tutorial -> Adding Comments and Search to an ASP.NET AJAX Server-Centric Based Online Shopping Website - Advanced Search continued(4)
Recommend
HOT TOP10
Adding Comments and Search to an ASP.NET AJAX Server-Centric Based Online Shopping Website - Advanced Search continued(4)
Date: 2008-1-4 Author: Hit: View:[Large font Middle font Small font]

In addition, we should notice that we’ve designed the "advanced search" function just for integrity, for it only searches goods that must meet the four given conditions at the same time, as is proved by the following SQL script for the stored procedure (i.e. Pr_AdvanceSearchProduct) we need here.

ALTER PROCEDURE Pr_AdvanceSearchProduct(

@Name varchar(200),

@Sell varchar(200),

@MinDate datetime,

@MaxDate datetime,

@MinPrice money,

@MaxPrice money

)

AS

SELECT

*

FROM

Product

WHERE

Name like '%' + @Name + '%' AND Sell like '%' + @Sell + '%'

AND SellInDate >= @MinDate AND SellInDate <= @MaxDate

AND OutPrice >= @MinPrice AND OutPrice <= @MaxPrice

Next, after the use populates the searching data and click button ‘Start to search…’, the following event handler will be invoked:

protected void CommitBtn_Click(object sender,EventArgs e){

Product product = new Product();

DataSet ds = new DataSet("Product");

ds.Tables.Add(product.AdvanceSearchProduct(Name.Text,Sell.Text,

DateTime.Parse(MinDate.Text),DateTime.Parse(MaxDate.Text),

Decimal.Parse(MinPrice.Text),Decimal.Parse(MaxPrice.Text)));

ProductView.DataSource = ds;

ProductView.DataBind();

ProductView.Visible = ProductView.Rows.Count <= 0 ? false : true;

lblHint.Visible = ProductView.Rows.Count <= 0 ? true : false;

}

Apparently, the key lies in the member function named AdvanceSearchProductof the Product class, which further calls the above mentioned stored procedure Pr_AdvanceSearchProductto finish the research. By attaching the result dataset to the ProductView control and making it visible we finally see the results as shown in the above Figure 23.


DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

(From: aspfree)

Relative article:
·Adding Comments and Search to an ASP.NET AJAX Server-Centric Based Online Shopping Website(1)
·Adding Comments and Search to an ASP.NET AJAX Server-Centric Based Online Shopping Website(2)
·Adding Comments and Search to an ASP.NET AJAX Server-Centric Based Online Shopping Website(3)
Relative software: