Saturday, April 2, 2016

Append QueryString to PostBackUrl attribute in LinkButton Control

There was a question raised in the forum on how to append query string to a PostbackUrl attribute in an ASP.NET LinkButton inside the template field of a GridView control.

To answer that, one possible solution is to set the PostBackUrl with String.Format() method where you can include the desired query string of that url.
1
2
3
4
<asp:LinkButton ID="lnkProductPage" runat="server" 
    PostBackUrl='<%# String.Format("ProductPage.aspx?Id={0}", Eval("ID"))%>' 
    CausesValidation="false" Text='<%# Eval("ID")%>'>
</asp:LinkButton>

0 comments:

Post a Comment