1

I have a gridview that has a column that has a Hyperlink control as wellas a LinkButton control. As such:

 <asp:TemplateField HeaderText="Actions">
    <ItemTemplate>
        <asp:HyperLink ID="linkEdit" runat="server"  NavigateUrl="~/shipment.aspx">Edit</asp:HyperLink> | 
        <asp:LinkButton ID="linkSend" runat="server">Send</asp:LinkButton>
    </ItemTemplate>
    <ItemStyle Width="76" HorizontalAlign="Center" />
 </asp:TemplateField>

Each row will have an "Actions" column that looks like this: Edit | Send

How do I set the NavigateUrl property of the Hyperlink in each row to include a value from the first column of the row?

Example: NavigateUrl="~/shipment.aspx?edit=VALUE_FROM_COLUMN_0_OF CURRENT_ROW"

2 Answers 2

1

Try

<asp:HyperLink ID="linkEdit" runat="server"  
     NavigateUrl='<%# "~/shipment.aspx?edit=" + Eval("IdField")" %>' >Edit</asp:HyperLink>
Sign up to request clarification or add additional context in comments.

2 Comments

I tried that already all I get is error: Compiler Error Message: CS1010: Newline in constant
Figured it out: NavigateUrl='<%# DataBinder.Eval(Container.DataItem, "shipment_id", "~/shipment.aspx?edit={0}") %>'
1

Give this a shot:

asp:HyperLink ID="lnkEdit" runat="server" NavigateUrl='<%# String.Format("~/shipment.aspx?edit={0}", Eval("SomeID")) %>' ...>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.