C# response.redirect传递多参

来源:互联网 发布:淘宝书店赚钱吗 编辑:程序博客网 时间:2024/05/23 12:06

还是老规矩,简单的就直接上代码,直观。

下面这行代码是1.aspx文件的button事件:本页面有几个文本框,是一些查询条件啦,button1是搜索按钮啦。因为我要把查出来的东西放到2.aspx的datagrid里面显示出来,所以干脆直接把参数传过去,在那边查,那边显示咯。

 protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Redirect("Company.aspx?Companyname=" + Companyname.Text + " &&Companycode=" + Companycode.Text + " &&Companyperson=" + Companyperson.Text + " &&Tel=" + Tel.Text + " &&Mail=" + Mail.Text);
    }

 

下面讲诉2.aspx如何调用:

 protected void Page_Load(object sender, EventArgs e)
    {
        int isnull = -1;
        string Companyname = Request.Params["Companyname"];
        string Companycode = Request.Params["Companycode"];
        string Companyperson = Request.Params["Companyperson"];
        string Tel = Request.Params["Tel"];
        string Mail = Request.Params["Mail"];
        if (Companyname==null && Companycode==null && Companyperson==null && Tel==null && Mail==null)
            isnull = 0;
        if (isnull != 0)
        {
            BindOneCompany(Companyname, Companycode, Companyperson,Tel,Mail);
        }
        else
        {
            BindCompany();
        }

}

给各位解惑了吗?怎么说呢,不知道这个方法是不是笨拙了点,不过我自学自编,能够出结果,感觉是灰常开心啦。。。

 

 

 

原创粉丝点击