Click here to Skip to main content
15,890,741 members
Please Sign up or sign in to vote.
3.50/5 (2 votes)
See more:
Improved Question.. Updated.

First i have a problem of getting the ProductIds from main page to Product Catalog.aspx Page..
Now when i make some Changes in the coding as below. i am getting the ProductsIDs form main page to ProductCatalog.aspx page.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()
   {

      // string query = "Select * from Products where CategoryID='" + Request.QueryString["ID"] + "' Or ProductID ='" + Request.QueryString["ID"] + "'or '"+int.TryParse(Request.QueryString["PriceID"]<5000)+"'";// or ProductName='"+Request.QueryString["Name"]+"'";
      // if (Request.QueryString["ID"] != "" && Request.QueryString["ID"] != null)
      // {


          // string query = "Select * from Products where ProductID= " + proid + " AND UnitCost < 5000";
          // string query = "Select * from Products where ProductID= '" + Session["mysession"] + "' AND UnitCost < 5000";

          // string query = "Select * from Products where ProductID= " +Session["mysession"] + " AND UnitCost < 5000";

       if (Request.QueryString["ID"] != null && Request.QueryString["ID"].ToString() != "")
       {
          // string query = "Select * from Products where ProductID= " + Request.QueryString["ID"].ToString() + " AND UnitCost < 5000";

           string query = "Select * from Products where ProductID= '" + Request.QueryString["ID"].ToString() +"' AND UnitCost < 5000";
           //string query = "Select * from Products where ProductID= '" + Request.QueryString["ID"].ToString() + "' AND UnitCost < 5000";
           //DataSet ds = new DataSet();
           DataSet dss = obj.fillgrid(query);
           GridView1.DataSource = dss.Tables[0];
           GridView1.DataBind();
       }
       //}
       //conn.Close();
   }


i put loadgridview on page load
Posted
Updated 27-Dec-11 16:56pm
v4

hi frnd

you can write you logic as per below code

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

            Response.Redirect("your page name"?ID=proid);


and into another page:

C#
if(Request.QueryString["ID"] !=null && Request.QueryString["ID"].toString() != "")
{
 string query = "Select * from Products where ProductID= '" + Request.QueryString["ID"].ToString() + "' AND UnitCost < 5000"; //request.querystring should
}


let me know is this solution is help.
 
Share this answer
 
v4
Comments
codegeekalpha 26-Dec-11 6:43am    
i will tell u .. after the implementation.. i am out of house now..
codegeekalpha 26-Dec-11 13:48pm    
this results nothing.. in productCatalog.aspx
Nigam Patel 26-Dec-11 22:19pm    
can you able to debug it and check the value of the querystring ?
are you able to get the value of querystrin on productCatalog page?
Nigam Patel 26-Dec-11 22:29pm    
i update the my solution. please use it and let me know is this helpful to you?
codegeekalpha 27-Dec-11 21:41pm    
if(proid == String.Empty)
{
proid = Convert.ToInt16( dr["ProductID"]); // i am getting error here cannot convert type short to int
}
I am giving one approch. You can do this by comma separate. Take hidden variable on main page.

C#
input type="hidden" name="pdids" id="pdids" runat="server" />

in page one you need to append ids to this hidden variable.
C#
string querydr = "select * from Products";
            SqlDataReader dr = obj.fillcomb(querydr);
		string proid =null;
            while (dr.Read())
            {
                 proid += string.Format("{0}-", Convert.ToInt16(dr["ProductID"]));

             }
pdids.Value=proid ;


In page to you will access it like bellow
C#
if(!string.IsNullOREmpty(Request.QueryString["pdids"]))
{
string query = "Select * from Products where ProductID= '" + Request.QueryString["pdids"].ToString() + "' AND UnitCost < 5000";
}
 
Share this answer
 
Comments
codegeekalpha 26-Dec-11 12:04pm    
its not working
codegeekalpha 27-Dec-11 22:48pm    
check updated question
There are a couple of ways you can do it:

1) Via the redirect string:
www.mydomain.com/mypage?id1&id2&id3

2) Via Cookies
3) Via Session variables.

Google will tell you how to use each of them. Your choice, but I would probably use the Session.
 
Share this answer
 

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