使用会话将数据一页一页地传输到另一页 [英] transfer data one page another page using session
问题描述
嗨
我正在为客户编写一个登录页面,登录后它将在下一页显示所有客户数据.
我正在使用会话.它只能在传输ID和其他项目的情况下工作.
我正在写下面的代码.所以,请找出错误并给我解决该问题的想法....
Hi
I am writing a Login page for customer, after login it will display all customer data on the next page.
i am using sessions. its working but only with transfer id and other items are not transfered.
i am writing the code below. So, please find error and give me the idea to solve this problem....
string cuser_id = TextBox1.Text;
balcon obj1 = new balcon();
string ckkk = obj1.dataaccount(cuser_id).ToString();
if (ckkk == " Sorry No Id Found")
{
Label1.Text = "Sorry no id found";
}
else
{
Session["aaa"] = cuser_id.ToString();
Response.Redirect("customer.aspx");
}
第二页代码是
2 nd page code is
account_details obj5 = new account_details();
obj5.Account_id = (int32)Session["aaa"];
obj5.Account_id = TextBox1.Text;
obj5.Name = TextBox2.Text;
obj5.Join_date = TextBox3.Text;
obj5.Balance = TextBox4.Text;
推荐答案
请从MSDN阅读Session的基础知识.请检查以下链接,这将对您有所帮助.
http://msdn.microsoft.com/en-us/library/ms178581.aspx [ ^ ]
http://msdn.microsoft.com/en-us/library/ms972429.aspx [ ^ ]
Please read the basic of Session from MSDN. Please check the below links this will help you.
http://msdn.microsoft.com/en-us/library/ms178581.aspx[^]
http://msdn.microsoft.com/en-us/library/ms972429.aspx[^]
首先,这个问题不清楚.向可以更好地处理英语的人寻求帮助会更好.
然后,如果您只希望传递 cuser_id 并且仅在目标页面中希望此值,则最好使用 ^ ].
First of all, this question is not clear. It will be better to get help from someone who can handle English in a better way.
Then, If you want to pass only cuser_id and you want the value of this only in the destination page, better use Query-String[^].
obj5.Account_id = Session["aaa"].ToString();
obj5.Account_id = TextBox1.Text;
在上面的代码中,删除第二行,因为它覆盖了 obj5.Account_id .
问候
塞巴斯蒂安
In the above code, remove the second line as it overwrites the obj5.Account_id.
Regards
Sebastian
在您的第一页中
In your 1st page
string qid = "121";
Session["QueryString"] = qid;
要在第二页中接收数据,请使用
perWorkId = Convert.ToString(Session ["QueryString"]);
To receive the data in the 2nd page use
perWorkId = Convert.ToString(Session["QueryString"]);
这篇关于使用会话将数据一页一页地传输到另一页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!