1

I'm trying to add column to ASPxGridView which would have link to other page:

  <Columns>
        ...
        <dxwgv:GridViewDataColumn Caption=" " VisibleIndex="10">
            <DataItemTemplate>
                <dxe:ASPxHyperLink ID="lnkEdit" runat="server" Text="Edit" NavigateUrl="../Category/Elements/<%# Eval("Id").ToString() %>/Edit"/>
            </DataItemTemplate>
        </dxwgv:GridViewDataColumn>
    </Columns>

But I get error:

Parser Error Message: The server tag is not well formed.

when I used ' ' instead " " the link href property is "../Category/Elements/<%# Eval("Id").ToString() %>/Edit"

TrN
  • 1,230
  • 2
  • 17
  • 32
  • 2
    Looks like you have a good answer already, but I think it might also work if you just change the outer quotes to single, I know in some cases that works, just not sure about this one. For sure double-quotes inside double-quotes pretty much never works. – eselk Jan 27 '12 at 17:31

1 Answers1

3

I don't think you can put databinding elements into the middle of the attribute value. The entire value needs to be within the <% %>:

NavigateUrl='<%# "../Category/Elements/" +  Eval("Id").ToString() + "/Edit" %>'

I'm not sure with UI library you're using, but usually the Eval() allows a string format parameter. This would be preferable to the string concatenation approach. You might be able to do:

NavigateUrl='<%# DataBinder.Eval(Container.DataItem, "Id", "../Category/Elements/{0}/Edit") %>'
Cᴏʀʏ
  • 105,112
  • 20
  • 162
  • 194