Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP:LinkButton and Eval

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?

like image 271
sgibbons Avatar asked Feb 23 '09 19:02

sgibbons


1 Answers

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.

like image 160
eglasius Avatar answered Oct 10 '22 00:10

eglasius