price = '" + price_range+ "' it get only string as below Rs.500/- instead of this how can get values of less than 500 from database.
protected void BulletedList3_Click(object sender, BulletedListEventArgs e) { price_range = BulletedList3.Items[e.Index].Value; if (con.State == ConnectionState.Closed) { con.Open(); } switch (price_range) { case "Below Rs.500/-": SqlCommand cmd = new SqlCommand("select pro_img,pro_name,price from product where price = '" + price_range+ "' and status='A' and type='retail' ", con); SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds); DataList1.DataSource = ds; DataList1.DataBind(); con.Close(); break; case "Rs.500/- to Rs.1000/-": SqlCommand cmd1 = new SqlCommand("select pro_img,pro_name,price from product where price = '" + price_range + "' and status='A' and type='retail' ", con); SqlDataAdapter da1 = new SqlDataAdapter(cmd1); DataSet ds1 = new DataSet(); da1.Fill(ds1); DataList1.DataSource = ds1; DataList1.DataBind(); con.Close(); break; case "Rs.1000/- To Rs.2000/-": SqlCommand cmd2 = new SqlCommand("select pro_img,pro_name,price from product where price = '" + price_range + "' and status='A' and type='retail' ", con); SqlDataAdapter da2= new SqlDataAdapter(cmd2); DataSet ds2 = new DataSet(); da2.Fill(ds2); DataList1.DataSource = ds2; DataList1.DataBind(); con.Close(); break; default: break; } }
between and
Select * from table where price between 500 and 1000
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)