Reputation: 1750
I want to bind data to a templatefield in asp.net. I know you do this with the following code
Text = '<%#Bind("ColumnName") %>'
Where Text is the Text Property of the control I want to bind it to. However I want to bind a another thing to my text in the control, I want to bind to a Hyperlink's NavigateUrl the following:
"Default.aspx?id="
and bind this to and id from a database. How can I achieve this? Thank you.
Upvotes: 1
Views: 1314
Reputation: 2895
You could have something like below:
NavigateUrl='<%# "Default.aspx?id=" +Eval("id") %>'
Upvotes: 1
Reputation: 2788
Try This.
<asp:HyperLink ID="HyperLink1" NavigateUrl='<%# "~/Default.aspx?id=" + Eval("something") %>' runat="server">HyperLink</asp:HyperLink>
Upvotes: 1
Reputation: 460148
Perhaps:
NavigateUrl='<%# String.Format("Default.aspx?id={0}&nextParam={1}", Eval("ID"), Eval("NextColumn")) %>'
Upvotes: 2