SELECT * FROM [Products] where Categotyid = @CategoryId and Price between @pricestart and @priceend
SELECT * FROM [Products] where CategotyId = @CategoryId and Name LIKE @Brands + '%'
SELECT * FROM [Products] where Categotyid = @CategoryId and Name LIKE @Brands + '%' and Price between @pricestart and @priceend
and this my code to retrieve data from database...
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//dlCustomers.DataSource = GetCustomersData(pageindex,categoryid,brands,price);
dlCustomers.DataSource = GetCustomersData(1, 0, null, 0);
dlCustomers.DataBind();
}
}
public static DataSet GetCustomersData(int pageindex, int customerId, string brands, int price)
{
string query = "Getproducts9";
//string query = "[GetCustomersPageWise]";
SqlCommand cmd = new SqlCommand(query);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@PageIndex", pageindex);//1
cmd.Parameters.AddWithValue("@PageSize", 12);//2
cmd.Parameters.AddWithValue("@CategoryId", customerId);//3
cmd.Parameters.AddWithValue("@Brands", brands);//4
cmd.Parameters.AddWithValue("@Price", price);//5
cmd.Parameters.Add("@PageCount", SqlDbType.Int, 4).Direction = ParameterDirection.Output;
return GetData(cmd);
}
private static DataSet GetData(SqlCommand cmd)
{
string strConnString = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
using (SqlConnection con = new SqlConnection(strConnString))
{
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.Connection = con;
sda.SelectCommand = cmd;
using (DataSet ds = new DataSet())
{
sda.Fill(ds, "Customers");
DataTable dt = new DataTable("PageCount");
dt.Columns.Add("PageCount");
dt.Rows.Add();
dt.Rows[0][0] = cmd.Parameters["@PageCount"].Value;
ds.Tables.Add(dt);
return ds;
}
}
}
}