DataList中实现页面跳转(另:替代Response.Redirect的跳转页面语句)

方法(1):
<asp:datalist
<itemtemplate>
<a href='detail.aspx?id=<%# Eval("ID") %>'><%# Eval("Name") %></a>
或:
<asp:hyperlink navigateurl='<%# Eval("ID", "showdetail.aspx?id={0}") %>' text=<%# Eval("Name") % runat=server />
<itemtemplate>
方法(2):
<asp:datalist OnItemCommand="DataList_ItemCommand"
<itemtemplate>
<asp:LinkButton ID="LinkButton" Runat="server" Text="详细" CommandName='<%# Eval("ID") %>'/>
<itemtemplate>
后台:
protected void DataList_ItemCommand(object Sender, DataListCommandEventArgs e)
    {
        string str = e.CommandName;
        string id = "";
        //未放置UpdatePanel,使用如下语句跳转页面
        //Response.Redirect("showdetail.aspx?id="+str);
        ClientScript.RegisterStartupScript(this.GetType(), "clientScript", "<script language='javascript'>window.open('showdetail.aspx?str="+str+"');</script>");
        //设置UpdatePanel,使用如下语句跳转页面
        //ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "clientScript", "window.open('showdetail.aspx?str=" + str + "');", true);
    }

你可能感兴趣的:(response)