我使标签具有来自数据库的价值并将其链接起来。但问题是它只有一个值,我希望它在导航时认为网站保持价值。
X> Y> Z> ....
这是我的代码
<
if(Request.QueryString [“Category_Id”]!= null) {
Banar.ImageUrl = "Handlers/Banner.ashx?Category_Id=" + Request.QueryString["Category_Id"] + "";
using
(SqlConnection conn = Connection.GetConnection())
{
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "Navcategory";
cmd.Parameters.Add(Parameter.NewInt("@Category_Id", Request.QueryString["Category_Id"]));
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
LblNavigaton.Visible = true;
LblNavigaton.Text = dr[i].ToString();
NavHref.HRef = "ListView.aspx?Category_Id=" + Request.QueryString["Category_Id"] + "";
}
}
}
else if (Request.QueryString["ProductCategory_Id"] != null)
{
Banar.ImageUrl = "Handlers/ProCatBanner.ashx?ProductCategory_Id=" + Request.QueryString["ProductCategory_Id"] + "";
using
(SqlConnection conn = Connection.GetConnection())
{
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "NavProductcategory";
cmd.Parameters.Add(Parameter.NewInt("@ProductCategory_Id", Request.QueryString["ProductCategory_Id"]));
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
LblNavigaton.Visible = true;
LblNavigaton.Text = dr["Name"].ToString();
NavHref.HRef = "ListView.aspx?ProductCategory_Id=" + Request.QueryString["ProductCategory_Id"] + "";
}
else
{
LblNavigaton.Visible = true;
LblNavigaton.Text = Page.Title;
}
}
答案 0 :(得分:0)
好吧,您可以在每次加载新网页时检索该值,或将其作为网址参数传递,或者阅读cross-page posting。
答案 1 :(得分:0)
如果您想在用户登录时将该值保留在<{1}}“整个”网站中,那么您可以在这种情况下使用LblNavigaton.Text
。比如:
Session