Hi,
I want to pass cid genarated in selling.aspx to orderform.aspx .
How to retrieve the query string in orderform.aspx
I gave the code below in selling.aspx

SqlConnection con;
        SqlDataReader dr;
        con = new SqlConnection("Persist Security Info=False;Uid=sa;Password=q1w2e3/;Initial Catalog=YOGADATA;Data Source=PC-1");
        con.Open();
        t=0;
        
        SqlCommand com = new SqlCommand("select * from Custlogin", con);
        dr = com.ExecuteReader();
        dr.Read();
        
        try
        {
            do
            {
                if (TextBox1.Text.Trim() == dr[0].ToString().Trim() && TextBox2.Text.Trim() == dr[1].ToString().Trim())
                
                {
                    t = 1;
                    id = dr[2].ToString().Trim();
                }
            } while (dr.Read());
        }

        catch
        {
        }
        finally
        {
            con.Close();
            dr.Close();
        }
        if (t == 1)
        {
           [B][U] Response.Redirect("Orderform.aspx?id=");[/U][/B]        }
        else
        {
           Label11.Visible = true;
           Label11.Text = "Login failed,try again";

        }

please help me soon
Thank U.

Recommended Answers

All 4 Replies

Try this:

string customerId = Request.QueryString["id"];

Hi,
I have tried the same;
It is giving Null string.
Is there any wrong in my above code?
Thank You.

If you receive a null string it is because the query string was not passed in the request. You also need to read the Request.QueryString[] in the page that is receiving the request. IE if you call Response.Redirect("Orderform.aspx?id="); then you need to be reading the query string inside of OrderForm.aspx's page load event.

Here is some sample output of query strings:

--------
id[B]:[/B]  
url: /frmDevex.aspx
--------
id:  1234
url: /frmDevex.aspx?id=1234
--------
id:  1234
url: /frmDevex.aspx?ID=1234
--------
id:  
url: /frmDevex.aspx?ID=&abc=123

It's a security problem to write the id in the params string but you can do it like this:

Response.Redirect("Orderform.aspx?id=TheIdTextBox.text");

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.