Click here to Skip to main content
15,894,343 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i am sending productids from mainpage to productcatalog.aspx and then generating the query on the bases of these ids to show data in grid..
i have different links on page.. one link is Price <5000 and one link is Price between 5000 and 1000. i put the fallowing code in 5000 link event. on main page.


C#
while (dr.Read())
{
   if(proid == String.Empty)
   {
      proid =  dr["ProductID"].ToString(); 
   }
   else
   {
      proid += "," + dr["ProductID"].ToString();
   }
}


i want to do the same procedure for link between of price between 5000 to 1000 which is on main page

but i have a problem of showing the data in productcatalog.aspx page on the bases of different links.

for products price <5000 i have written the code which works fine is as below

just on page load i fill the grid using data adapter on the base of this query

C#
string query = "Select * from Products where ProductID= '" + Request.QueryString["ID"].ToString() +"' AND UnitCost < 5000";


what i have to do to put another query for UnitCost between 5000 and 10000

i.e the query would be as below.

C#
string query = "Select * from Products where ProductID= '" + Request.QueryString["ID"].ToString() +"' AND UnitCost between 5000 and 10000"


but how can i write that query in productcatalog.aspx. so that both queries works fine.
C#

Posted
Updated 28-Dec-11 23:54pm
v2
Comments
Dinesh Mani 28-Dec-11 23:58pm    
I don't get it... One product can have only one unit cost right?? Then why do you wish to execute multiple queries for the same product id???
codegeekalpha 29-Dec-11 0:02am    
i am filling grid on the bases of price range..
first is for products with unitcost<5000 and other one is for price range between 5000 and 10000

1 solution

hi farooq,


please change the query as per below code

SQL
string query = "Select * from Products where ProductID in (" + Request.QueryString["ID"].ToString() +") AND UnitCost < 5000";


here , if ProductID field has int datatype then query become like

productID in (1,2,3,4,5) like this,

and if productID field has varchar datatype or nvarchar datatype then

productId in ('1','2','3','4')

hope this solution will help....:)
 
Share this answer
 
Comments
codegeekalpha 28-Dec-11 23:56pm    
i think you hav'nt understand my question..
Nigam Patel 29-Dec-11 3:22am    
ok at a time you want to run both query or only one query
codegeekalpha 29-Dec-11 5:55am    
only one query at a time
Nigam Patel 1-Jan-12 23:00pm    
for that you need to pass one more query string which says what kind of Unit cost condition you want to run. you can define int for it or directly pass the condition.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900