Here is how you can add a database value to the URL of a HyperLink that is in a GridView. In this example the text displayed is the same as the value added to the URL. Also the data is bound through a SqlDataSource and the “ID” value is from the output of the Select statement the SqlDataSource uses. This is a quick way to put the data in the URL without using any code in the code behind.
<asp:TemplateField HeaderText="ID" >
<ItemTemplate>
<asp:HyperLink ID="hlID" runat="server" Text='<%# EVAL("ID") %>' NavigateUrl='<%#"Default.aspx?ID=" + EVAL("ID") %>'/>
</ItemTemplate>
</asp:TemplateField>
Technorati Tags:
ASP.Net,
GridView