页面间如何传递参数

<asp:GridView ID="StudentGridView" runat="server">
         <Columns>
         <asp:TemplateField HeaderText="选择">
         <ItemStyle HorizontalAlign="Center" Height="35px" Width="720px" />
         <ItemTemplate>
             <asp:Button ID="CheckButton" runat="server" Text="查看" CommandArgument='<%# Eval("code") %>' OnCommand="CheckButton_Click"/>
         </ItemTemplate>
</asp:GridView>

protected void CheckButton_Click(object sender, CommandEventArgs e)
    {
        string studentCode = e.CommandArgument.ToString();
        Response.Redirect("StudentResource.aspx?" + studentCode);//因为两个页面同在一个文件夹下面所以只写了页面的名称,不然要写绝对路径的
    }
   
   
    在另一个页面(次页面的名字为StudentResource.aspx)里面
    protected void  Page_Load(object sender, EventArgs e)
    {
        string  studentCode = Request.QueryString.ToString();
    }

例二:
页面一:
<asp:LinkButton ID="lbDel" runat="server" Text="删除" CommandName="DeleteUser"
                                     CommandArgument='<%# DataBinder.Eval(Container.DataItem, "UserName") %>' OnCommand="LinkButtonClick"
                                      ForeColor="blue" OnClientClick="return confirm('确定要删除该用户吗?');">
                                    </asp:LinkButton>

protected void LinkButtonClick(object sender, CommandEventArgs e)
    {
        if (e.CommandName.Equals("EditUser"))
        {
            Response.Redirect("edituser.aspx?user=" + e.CommandArgument.ToString());
        }

}

页面二:

protected void btSubmit_Click(object sender, EventArgs e)
    {
        string username=Request.QueryString["user"];

        try
        {
            string email = txtEmail.Text;
            MembershipUser mu = Membership.GetUser(username);
            mu.Email = email;
            Membership.UpdateUser(mu);
            lbMessage.Text = "更新成功!";
        }
        catch (System.Configuration.Provider.ProviderException ex)
        {
            lbMessage.Text = ex.Message;
        }
    }
}


 

posted @ 2007-12-06 17:24  不染丹心  阅读(549)  评论(0编辑  收藏  举报