pjx131 2016-04-13 16:49 采纳率: 50%
浏览 1527

关于不同页面间将session的值传到另一个页面的GridView中

搜索按钮在这个页面production.aspx
protected void searchbtn_Click(object sender, EventArgs e)
{
if (searchtb.Text == "")
{
Response.Write("alert('请输入查找的内容!');location.href='production.aspx'");
}
else
{
Session["searchprotype"] = searchddl.SelectedItem.Text;
Session["searchkey"] = searchtb.Text;
Response.Redirect("productionsearch.aspx");

    }
 protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        if (Session["searchkey"].ToString() != "")
        {
            try
            {
                fill();
            }
            catch
            {
                Response.Redirect("../AVSU/production.aspx");
            }
        }
    }
    else
    {
        Response.Redirect("../AVSU/production.aspx");
    }
}
        public void fill()
{
    string select;
    if (Session["searchprotype"].ToString() == "农产品名称")
    {
        select = string.Format("select proid as 编号,proname as 农产品名称,proprice as 价格,pronum as 数量,proaddress as 产地,prodata as 日期,protype as 类型 from tb_production where proname like '%"+Session["searchkey"].ToString()+"%'");
    }
    else if (Session["searchprotype"].ToString() == "农产品类型")
    {
        select = string.Format("select proid as 编号,proname as 农产品名称,proprice as 价格,pronum as 数量,proaddress as 产地,prodata as 日期,protype as 类型 from tb_production where protype like '%"+Session["searchkey"].ToString()+"%'" );
    }
    else
    {
        select = string.Format("select proid as 编号,proname as 农产品名称,proprice as 价格,pronum as 数量,proaddress as 产地,prodata as 日期,protype as 类型 from tb_production where proaddress like '%"+Session["searchkey"].ToString()+"%'" );
    }
    searchgv1.DataBind();
}

请各位帮我看下有什么问题,我在按钮的页面试了下,session的值可以得到,不过到另一个页面就显示不出来了,可是我又找不到哪里出错,拜托各位大神了!

  • 写回答

1条回答

  • threenewbee 2016-04-13 22:53
    关注

    Session["searchprotype"] = searchddl.SelectedItem.Text;
    这里下断点调试下。

    评论

报告相同问题?

悬赏问题

  • ¥20 fluent无法启动
  • ¥15 孟德尔随机化r语言运行问题
  • ¥15 pyinstaller编译的时候出现No module named 'imp'
  • ¥15 怎么把多于硬盘空间放到根目录下
  • ¥15 Matlab问题解答有两个问题
  • ¥50 Oracle Kubernetes服务器集群主节点无法访问,工作节点可以访问
  • ¥15 LCD12864中文显示
  • ¥15 在使用CH341SER.EXE时不小心把所有驱动文件删除了怎么解决
  • ¥15 gsoap生成onvif框架
  • ¥15 有关sql server business intellige安装,包括SSDT、SSMS。