Click here to Skip to main content
15,902,840 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi I am writing code which sends email to a person with button in it to track
shipping. The page the button is calling takes two input values tID and dID
url like,
www.shippingcompany.com/tracking.aspx?tID=234003&dID=tx2333

When i use this above link with button click action it doesnt work, displays the normal page to enter values manually. Any ideas how to go about doing it?
Thanks
Posted
Comments
Sergey Alexandrovich Kryukov 20-Jun-12 23:24pm    
Any idea? Sure, here is one: create a code sample manifesting the problem, short but complete, and post it using "Improve question". At list show the code snippet, a key code fragment. Also, what happens it you do it through a "regular" Web browser? Because how do I know that the site itself works as expected with your parameters?
--SA

1 solution

You should pass the same thing on Page Load for Tracking.aspx code for Loading Data. i.e. you want page to Load tID and dID when you click button and page loads.
To Load Values from database just use syntax like below on Tracking.aspx

In my case I used GridView because I Need more than one value. code is below on PageLoad.

C#
// Code for Tracking.aspx

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindDList();
        }
    }

    void BindDList()
    {
        string PCode = Request["PCode"].ToString();
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MyShop"].ConnectionString);
        SqlDataAdapter adp = new SqlDataAdapter("Select * from Products where ProductID in (" + PCode + ")",con);
        DataSet ds = new DataSet();
        adp.Fill(ds);
        GView1.DataSource = ds.Tables[0];
        GView1.DataBind();
    }


Now code for Button Click from where you want to send tID and dID in my case PCode is here.
If you are using Grid View in page then code is like this:
C#
string PCode = "";
Label lblPCode = (Label)DList1.Items[i].FindControl("PCode");
PCode = lblPCode.Text;
Response.Redirect("Tracking.aspx?PCode=" + PCode);


And if you are simply sending IDs from table or Div change your code like this,
C#
string tID = txtTID.Text;
string dID = txtDID.text;
Response.Redirect("Tracking.aspx?tID="+tID+"&dID="+dID);


Good Luck...
 
Share this answer
 
v2

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