Reputation: 545
I want to have a Go Back link which goes to a page using a query string.
<asp:HyperLink ID="backLink" runat="server" NavigateUrl="../project.aspx?id={0}"></asp:HyperLink>
I use a SqlDataReader
elsewhere on my page so decided to use this to grab the ID that I wanted to pass to this hyperlink. The issue is when I tried to pass the value to this URL I kept getting errors that I was trying to convert int to string and no matter what I tried in converting it, it wouldn't allow me to use it.
I also tried something like this:
<asp:HyperLink ID="backLink" runat="server" NavigateUrl="../project.aspx?id=<%=variableName%>"></asp:HyperLink>
That didn't work either. It literally printed it instead of grabbing the value which might be because it was enclosed in double quotes?
What is the best way to grab an int (Column is configured as an int) from a SQL table and then pass that to asp.net in a way similar to the above?
Upvotes: 0
Views: 877
Reputation: 34846
In your code-behind (Page_Load), try this:
this.backLink.NavigateUrl = "../project.aspx?id=" + yourID.ToString();
Upvotes: 3