Click here to Skip to main content
16,022,737 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
First i have a problem of getting the ProductIds from main page to Product Catalog.aspx Page through querystring.
Now when i make some Changes in the coding as below. i am getting the ProductsIDs form main page to ProductCatalog.aspx page thorugh querystring.I Used debugger to check that. On main page i made the fallowing changes. now ids are going to productcatalog.aspx page.


C#
string querydr = "select * from Products";
           SqlDataReader dr = obj.fillcomb(querydr);
            
            while (dr.Read())
            {
                 
                if(proid == String.Empty)
                  {
                 proid =  dr["ProductID"].ToString(); 
                 }
              else
                 {
                     proid += "," + dr["ProductID"].ToString();
                }
 

                }
            
          
 
       Response.Redirect("ProductCatalog.aspx?ID="+proid);




I used Debugger to check that whats going on on ProductCatalog.aspx Page..


I saw that i am getting the fallowing thing in my query on product catalog.aspx page..

I put the query in productcatalog.aspx page as


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



and on dubbugger i saw that the query runs as below.



C#
query	"Select * from Products where ProductID= ',63,64,65' AND UnitCost < 5000"	string


the products with ids have 63 and 64 have price(UnitCost) <5000 but nothing is shown in gridview. can anyone help on that where is the problem

on ProductCatalog.aspx page i have the code as below



C#
private void LoadGridView()
   {


       if (Request.QueryString["ID"] != null && Request.QueryString["ID"].ToString() != "")
       {

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

           DataSet dss = obj.fillgrid(query);
           GridView1.DataSource = dss.Tables[0];
           GridView1.DataBind();
       }

   }


i put loadgridview on page load
Posted

Hi,

Query should be like this.i hope it will work..

query = "Select * from Products where ProductID in (63,64,65) AND UnitCost < 5000"
 
Share this answer
 
v2
Change your code like this

private void LoadGridView()
   {


       if (Request.QueryString["ID"] != null && Request.QueryString["ID"].ToString() != "")
       {

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

           DataSet dss = obj.fillgrid(query);
           GridView1.DataSource = dss.Tables[0];
           GridView1.DataBind();
       }

   }
 
Share this answer
 
Comments
codegeekalpha 28-Dec-11 0:58am    
grid still remain empty.. still having the same problem
Hi,

Your query generated is wrong

Query should be generated like this

query	"Select * from Products where ProductID in ('63,64,65') AND UnitCost < 5000"


Hope this will help :)

Thanks
Vinod
 
Share this answer
 
v2
Comments
codegeekalpha 28-Dec-11 0:29am    
???? how??
karthi18988 28-Dec-11 8:18am    
You cant pass all the condition in where=(63,64,65) for that you must use where IN (63,64,65)
Use split() in sql and split prodID and make query :

string Query = "Select * from Products where ProductID in (Select * from dbo.split( '" + Request.QueryString["ID"].ToString() +"', ',')) AND UnitCost < 5000";

Use above query, it will give your result.
 
Share this answer
 
Comments
codegeekalpha 28-Dec-11 0:57am    
still i am getting nothing in grid :(.

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