将会话保存到标签然后保存回数据库

时间:2013-05-13 19:52:56

标签: c# asp.net .net

我正在尝试将Session添加到我网站的标签中,然后将保存在标签中的号码保存回数据库。会话称为customerID

我一直试图通过

来调用Session
int vv = (int)Session["customerID"]
Label7.Text = vv; 
//I know this doesn't work but can't work out what I need to make the label display the variable.

然后我试图将其保存回数据库,如此

newCarsRow.CustomerID = Convert.ToInt32(Label7.Text.Trim());

我的问题是如何让标签显示customerID

中保存的int

1 个答案:

答案 0 :(得分:2)

string vv = Session["customerID"].ToString();
Label7.Text = vv;

您不能使int等效于Label的Text属性。