Click here to Skip to main content
16,010,553 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am tring to redirect the product ids from main page to productcatalog.aspx page to show some that in a grid on the base of productid from main page and price range..
but i am getting nothing in gridview..

here is the code in main page

C#
dbcon obj = new dbcon();
public string proid;

  protected void Page_Load(object sender, EventArgs e)
  {




  }

  protected void LinkButton4_Click(object sender, EventArgs e)
  {
      //string proid;

         string querydr = "select * from Products";
         SqlDataReader dr = obj.fillcomb(querydr);

          while (dr.Read())
          {

              if(proid != String.Empty)
                {
               proid = dr["ProductID"].ToString();
               }
            else
               {
                   proid += "," + Convert.ToInt16(dr["ProductID"]);
              }


              }



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


and on productcatalog.aspx page.. i am have the fallwing code. caling the fuction on page load of productcatalog.aspx
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();
       }



and in url i am getting
http://localhost:54681/myfinalproject/ProductCatalog.aspx?ID=65


where is the problem.
Posted
Updated 26-Dec-11 6:46am
v2

hi farroqspecials

you have to change below condition

if(proid == String.Empty)


Please let me know if this is work for you
 
Share this answer
 
 
Share this answer
 
first check weather you are getting id on your page or not. if yes then check ProductID column of product table is of nvarchar type or numeric.

Because i think that you are passing string ID in table and that is of numeric type so there is mismatch of type.

C#
private void LoadGridView()
   {
        if (Request.QueryString["ID"] != null && Request.QueryString["ID"].ToString() != "")
       {
           string query = "Select * from Products where ProductID= " + Convert.ToInt32(Request.QueryString["ID"].ToString()) + " AND UnitCost < 5000";
                      DataSet dss = obj.fillgrid(query);
           GridView1.DataSource = dss.Tables[0];
           GridView1.DataBind();
       }

Hope this will help you.
Don't forget to mark as answer if it helps. :)
 
Share this answer
 
Why you are using

SQL
if(proid != String.Empty)
                  {

Here is wrong.
 
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