.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> ASP.NET >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Sending Values through Query String on other Pages in ASP.NET

Posted By:Ashutosh Jha       Posted Date: July 03, 2014    Points: 200    Category: ASP.NET    URL: http://www.dotnetspark.com  

Here i am going to explain how one can send the values to the other page through query string in ASP.NET. This may help in many situations like in medical shop, doctor will save the details on one page and he/she may send the drug list to shop by this method.
 

Here i am going to explain how one can send the values to the other page through query string in ASP.NET. This may help in many situations like in medical shop, doctor will save the details on one page and he/she may send the drug list to shop by this method. Suppose a scenario where, a patient has reached out to doctor for the check up. Doctor will treat him/her and doctor will fill all the details like demographic details, drug details etc and he will save that form. Now Doctor needs to ask his assistant for the drug in this case doctor only need to send the medicine name. Here we can use query string. From the prescription page doctor will send the name of the drug and on the medicine page his assistant will receive the same. This can be done so easily as below-

Suppose doctor saves 5 medicine name as- med1,med2,med3,med4,med5 and patient name as well as id on the prescription page as below-

    cmd.Parameters.AddWithValue("@Prescription1", Pres1.Text);
            cmd.Parameters.AddWithValue("@Prescription2", Pres2.Text);
            cmd.Parameters.AddWithValue("@Prescription3", Pres3.Text);
            cmd.Parameters.AddWithValue("@Prescription4", Pres4.Text);
            cmd.Parameters.AddWithValue("@Prescription5", Pres5.Text);
    cmd.Parameters.AddWithValue("@Name", name.Text);
    cmd.Parameters.AddWithValue("@dies", des.Text);

Now once the details are saved in the database, doctor need to send these details to his assistant on drug page. Than he will first send the details from his page like below-

            Session["med1"] = Pres1.Text;
            Session["med2"] = Pres2.Text;
            Session["med3"] = Pres3.Text;
            Session["med4"] = Pres4.Text;
            Session["med5"] = Pres5.Text;
    Session["name"] = name.Text;
    Session["des"] = des.Text;

Here i have sent all the details through session.

Now on the drug page, receive all these values at the page load like below-

string nam = Session["name"].ToString();
string des = Session["des"].ToString();
        string me1 = Session["med1"].ToString();
        string me2 = Session["med2"].ToString();
        string md3 = Session["med3"].ToString();
        string md4 = Session["med4"].ToString();
        string md5 = Session["med5"].ToString();

Now define as many label on the drug page as needed for these values; In this case i need 7 labels , define them as below-

 <asp:Label ID="medi8" runat="server" Text=""></asp:Label>
Similarly define others also.
And now define the value we have received from prescription page to these labels like below-

        medi1.Text = me1.ToString();
        medi2.Text = me2.ToString();
        medi3.Text = md3.ToString();
        medi4.Text = md4.ToString();
        medi5.Text = md5.ToString();
        name.Text = nam.ToString();
        dis.Text = des.ToString();

That's all. With this you have received all the values through Query string and sessions on the other page !!

 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend