Home All Groups Group Topic Archive Search About

specifying a query string in an href dynamically

Author
25 Nov 2005 3:14 AM
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?

Author
25 Nov 2005 3:41 AM
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

Robert Rotstein wrote:
Show quoteHide quote
> 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?

Bookmark and Share