Passing a URL variable into a URL in a binded gridview

asp.net Bulgaria
  • 12 years ago
    Ok I pass the variable Branch in the URL and I'm able to access it and display it as a header like this:

    <%=Request.QueryString("Branch")%>

    Then depending on the branch I retrieve the correct branches products and bind it to a gridview in the gridview I have a hyperlink which links to a page called Reserve. Where I pass the productid of each product in the URL. 

    Either like this:

    <asp:HyperLinkField DataNavigateUrlFields="itemid" DataNavigateUrlFormatString="~/BBB_Staff.aspx?ProductId={0}" Text="Reserve" />

    Or in a template like this:

    <asp:TemplateField>

    <ItemTemplate>

    <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# Eval("itemid", "~/BBB_Staff.aspx?ProductId={0}") %>'

    Text="Reserve"></asp:HyperLink>

    </ItemTemplate>

    </asp:TemplateField>

     

    What I want to do is also pass the branch as a variable I've tried various ways but can't seem to figure it out. I've tried doing it like this:

    <asp:HyperLinkField DataNavigateUrlFields="itemid" DataNavigateUrlFormatString="~/BBB_Staff.aspx?ProductId={0}&Branch=<%=Request.QueryString("Branch")%>" Text="Reserve" />

    But keep getting various error messages, any ideas?

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.” - Antoine de Saint Exupéry