specifying a query string in an href dynamically

R

Robert Rotstein

I have a control that looks something like this:

<asp:DataList ... >
<ItemTemplate ... >
<table>
<tr>
<td image src='... <%# DataBinder.Eval(Container.DataItem,
"IncidentID") %>' </td>
<a runat="server" href="somepage.aspx">some text</a>
</tr>
</table>
</ItemTemplate>
</asp:DataList>

The image is rendered via a custom HttpHandler. What I want is to put
in a query string following the page reference in the href, something like

href="somepage.aspx?IncidentID=<somevalue>"

where <somevalue> would be computed. I tried putting
<%#DataBinder.Eval(Container.DataItem, "IncidentID")%> inside the href,
following the "IncidentID=", but it did not get evaluated. I assume
that there must be a very simple way of doing this (or its equivalent).
Can someone clue me in?
 
G

Garfield

Hi Robert,

I believe you can do it in this way:

<asp:hyperlink
NavigateURL='<%# "/somepage.aspx?IncidentID="+
DataBinder.Eval( Container.DataItem, "IncidentID" )%>'
Text='<%# DataBinder.Eval( Container.DataItem,"Some
text" )%>'
runat="server"/>

Hope that helps

Henry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top