在FormView asp.net中将Get Variable(QueryString)添加到PostBackUrl中

时间:2012-05-01 14:48:33

标签: asp.net

我有以下代码:

<asp:Button ID="InsertButton" runat="server" CausesValidation="True" 
                                    CommandName="Insert" Text="Add Form" 
             PostBackUrl="~/APPLICATION/FormView.aspx?postquestion="/>   

我使用FormView Control。

我需要将Request.QueryString [&#34; postquestion&#34;]变量添加到&#34; FormView.aspx?postquestion =&#34;对于PostBackUrl。

我在网上找到了以下代码,但是它无效:

PostBackUrl='<%# ="~/APPLICATION/FormView.aspx?postquestion=" + Request.QueryString  ["postquestion"].ToString() %>'

感谢您的帮助!

1 个答案:

答案 0 :(得分:2)

尝试分配这样的PostBackUrl

<asp:Button ID="InsertButton" runat="server" 
    CausesValidation="True" 
    CommandName="Insert" 
    Text="Add Form"          
    PostBackUrl='<%# string.Format("~/APPLICATION/FormView.aspx?postquestion={0}", Request.QueryString["postquestion"]) %>' />