How to pass values from textboxes on one page to a "another page"
-
hi, any one help me, How to pass values from textboxes on one page to a "another page" using session. I have the follwing code but it shows an error msg. public string PassingSession ; Session["strPharmacyId"] = txtPharmacyId.Text.Trim(); Session["strStoreName"] = txtStoreName.Text.Trim(); Session["strAddress1"] = txtAddress.Text.Trim(); Session["strCity"] = txtCity.Text.Trim(); Session["strState"] = txtState.Text.Trim(); PassingSession = PassingSession + Session["strPharmacyId"]; PassingSession = PassingSession + Session["strStoreName"]; PassingSession = PassingSession + Session["strAddress1"]; PassingSession = PassingSession + Session["strCity"]; PassingSession = PassingSession + Session["strState"]; Session["Pharmacy"] = PassingSession; dtSession = (DataTable)Session["Pharmacy"]; msg: "can't convert string to datatable";
-
hi, any one help me, How to pass values from textboxes on one page to a "another page" using session. I have the follwing code but it shows an error msg. public string PassingSession ; Session["strPharmacyId"] = txtPharmacyId.Text.Trim(); Session["strStoreName"] = txtStoreName.Text.Trim(); Session["strAddress1"] = txtAddress.Text.Trim(); Session["strCity"] = txtCity.Text.Trim(); Session["strState"] = txtState.Text.Trim(); PassingSession = PassingSession + Session["strPharmacyId"]; PassingSession = PassingSession + Session["strStoreName"]; PassingSession = PassingSession + Session["strAddress1"]; PassingSession = PassingSession + Session["strCity"]; PassingSession = PassingSession + Session["strState"]; Session["Pharmacy"] = PassingSession; dtSession = (DataTable)Session["Pharmacy"]; msg: "can't convert string to datatable";
Vijay.RG wrote:
dtSession = (DataTable)Session["Pharmacy"];
What you are doing over here?
cheers, Abhijit CodeProject MVP Web Site:abhijitjana.net My Latest Article : IIS Remote Debugging
-
Vijay.RG wrote:
dtSession = (DataTable)Session["Pharmacy"];
What you are doing over here?
cheers, Abhijit CodeProject MVP Web Site:abhijitjana.net My Latest Article : IIS Remote Debugging
-
hi, any one help me, How to pass values from textboxes on one page to a "another page" using session. I have the follwing code but it shows an error msg. public string PassingSession ; Session["strPharmacyId"] = txtPharmacyId.Text.Trim(); Session["strStoreName"] = txtStoreName.Text.Trim(); Session["strAddress1"] = txtAddress.Text.Trim(); Session["strCity"] = txtCity.Text.Trim(); Session["strState"] = txtState.Text.Trim(); PassingSession = PassingSession + Session["strPharmacyId"]; PassingSession = PassingSession + Session["strStoreName"]; PassingSession = PassingSession + Session["strAddress1"]; PassingSession = PassingSession + Session["strCity"]; PassingSession = PassingSession + Session["strState"]; Session["Pharmacy"] = PassingSession; dtSession = (DataTable)Session["Pharmacy"]; msg: "can't convert string to datatable";
Vijay.RG wrote:
PassingSession = PassingSession + Session["strPharmacyId"]; PassingSession = PassingSession + Session["strStoreName"]; PassingSession = PassingSession + Session["strAddress1"]; PassingSession = PassingSession + Session["strCity"]; PassingSession = PassingSession + Session["strState"]; Session["Pharmacy"] = PassingSession; dtSession = (DataTable)Session["Pharmacy"];
You do not this piece of code at all. You already have assigned the textbox values to the Session Objects, the only thing you need to do is to read it back in the next page. In between, your design looks screwed and you should rather reconsider thinking of design before starting coding.
Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
-
Vijay.RG wrote:
PassingSession = PassingSession + Session["strPharmacyId"]; PassingSession = PassingSession + Session["strStoreName"]; PassingSession = PassingSession + Session["strAddress1"]; PassingSession = PassingSession + Session["strCity"]; PassingSession = PassingSession + Session["strState"]; Session["Pharmacy"] = PassingSession; dtSession = (DataTable)Session["Pharmacy"];
You do not this piece of code at all. You already have assigned the textbox values to the Session Objects, the only thing you need to do is to read it back in the next page. In between, your design looks screwed and you should rather reconsider thinking of design before starting coding.
Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
-
Dont ever store Datatable in Session. It means a huge amount of data will be stored in Session, and for each user who browses the site. So it will eat up all the app pool memory. :sigh:
Abhishek Sur My Latest Articles Working with Excel using MDAC
Basics on LINQ and Lambda Expressions
Create .NET Templates -
Passing the session value to datatable object. DataTable dtSession=new DataTable(); dtSession ==> Datatable object.
I think you have already got the answer from Manas Post.
Vijay.RG wrote:
Passing the session value to datatable object.
Never do like that. It will cause very performance issue. :)
cheers, Abhijit CodeProject MVP Web Site:abhijitjana.net My Latest Article : IIS Remote Debugging
-
hi, any one help me, How to pass values from textboxes on one page to a "another page" using session. I have the follwing code but it shows an error msg. public string PassingSession ; Session["strPharmacyId"] = txtPharmacyId.Text.Trim(); Session["strStoreName"] = txtStoreName.Text.Trim(); Session["strAddress1"] = txtAddress.Text.Trim(); Session["strCity"] = txtCity.Text.Trim(); Session["strState"] = txtState.Text.Trim(); PassingSession = PassingSession + Session["strPharmacyId"]; PassingSession = PassingSession + Session["strStoreName"]; PassingSession = PassingSession + Session["strAddress1"]; PassingSession = PassingSession + Session["strCity"]; PassingSession = PassingSession + Session["strState"]; Session["Pharmacy"] = PassingSession; dtSession = (DataTable)Session["Pharmacy"]; msg: "can't convert string to datatable";
How can you convert a string to datatable because PassingSession is a string as you declared? Here you are assigning values to session
Vijay.RG wrote:
Session["strPharmacyId"] = txtPharmacyId.Text.Trim(); Session["strStoreName"] = txtStoreName.Text.Trim(); Session["strAddress1"] = txtAddress.Text.Trim(); Session["strCity"] = txtCity.Text.Trim(); Session["strState"] = txtState.Text.Trim();
No need of below code
Vijay.RG wrote:
Session["strState"] = txtState.Text.Trim(); PassingSession = PassingSession + Session["strPharmacyId"]; PassingSession = PassingSession + Session["strStoreName"]; PassingSession = PassingSession + Session["strAddress1"]; PassingSession = PassingSession + Session["strCity"]; PassingSession = PassingSession + Session["strState"]; Session["Pharmacy"] = PassingSession; dtSession = (DataTable)Session["Pharmacy"];
You have already filled the textbox value in session.Now it will be accessible throughout ther application.
Cheers!! Brij