views:

643

answers:

1

I'm using an ASP:LinkButton inside of an ItemTemplate inside of a TemplateField in a GridView. For the command argument for the link button I want to pass the ID of the row from the datasource that the gridview is bound to, so I'm doing something like this:

<asp:LinkButton ID="viewLogButton" CommandName="viewLog" CommandArgument="<%#Eval("ID")%>" Text="View Log" runat="server"/>

Unfortunately, the resulting HTML is this:

<asp:LinkButton ID="viewLogButton" CommandName="viewLog" CommandArgument="3" Text="View Log" runat="server"/>

It seems that it is parsing the Eval() properly, but this is somehow causing it not to parse the LinkButton tag and just dump it out as literal text. Does anyone know:

a) why this is happening and, b) what a good solution to this problem is?

+2  A: 

While it may not be causing it, I usually define it like this:

CommandArgument='<%#Eval("ID")%>'

Please post the rest of the GridView's markup, as it shouldn't be doing that.

eglasius
silly me, I guess the quotes did it. Thanks. I assumed that all the templates were parsed before the actual asp:* markup - guess not.
sgibbons
Just had the same problem and was about to ask the same question.
CJM