这是我写的代码
private void ViewUsers()
{
con.Open();
SqlCommand com = new SqlCommand();
com.Connection = con;
com.CommandText =
"SELECT FirstName + ' ' + LastName AS Name FROM Clients WHERE UserID=" + Session["userid"];
SqlDataReader data = com.ExecuteReader();
while (data.Read())
{
lblName.Text = data["Name"].ToString();
}
data.Close();
con.Close();
}
private void GetUserType()
{
con.Open();
SqlCommand com = new SqlCommand();
com.Connection = con;
com.CommandText =
"SELECT UserTypeID FROM Users WHERE UserID=" + Session["userid"];
SqlDataReader d2 = com.ExecuteReader();
if (d2["UserTypeID"].ToString() != "4")
{
Response.Redirect("ContactUS.aspx");
}
}
我怎样才能从Session["userid"]
其中ViewUsers()
获得价值GetUserType
?