0

我在gridview 中有一个链接按钮- onClick 应该重定向到一个blank.aspx 表单并带有一个ID。我已经这样做了,但我收到一个错误,即格式不正确:

<asp:LinkButton ID="lbView" runat="server" Text="View"
       OnClientClick="window.open('DocumentViewer.aspx?ID=<%# Bind("ID") %>')">
</asp:LinkButton>

我想知道这有什么问题,请您告诉我。谢谢你。

4

1 回答 1

0
<asp:LinkButton ID="lbView" runat="server" Text="View"
       OnClientClick="window.open('DocumentViewer.aspx?ID=<%# Eval("ID") %>')">
</asp:LinkButton>

如果上述 din 工作,那么试试这个..

    <asp:LinkButton ID="lbView" runat="server"  Text="View"   
           PostBackUrl="window.open('DocumentViewer.aspx?ID=<%# Eval("ID") %>')">
    </asp:LinkButton>

或者

     <asp:LinkButton ID="lbView" runat="server" Text="View"  
           PostBackUrl="window.open(&#34;DocumentViewer.aspx?ID='<%# Eval("ID")%>'&#34;)">
     </asp:LinkButton>

或者

为链接按钮提供 CommandName = "eject" .. 然后使用 GridView RowCommand 事件。

if(e.CommandName =="eject") 
{ 
int index = convert.ToInt32(e.CommandArgument);
string id = GridView1.DataKeys[idx].Value.ToString();
Response.redirect("DocumentViewer.aspx?‌​id='"+id+"'");
} 
于 2013-09-10T09:54:06.673 回答