I have an asp:DataGrid
with templated columns. Here's one of those columns:
<asp:TemplateColumn>
<ItemTemplate>
<asp:LinkButton ID="btnDetails"
Runat="server"
CommandName="details"
Text="Details"
Font-Size="0.8em"
CommandArgument='a=<%# Eval("a")%>&b=<%# Eval("b")%>' />
<...>
When the command fires, the CommandArgument
comes back unevaluated - it is the str开发者_JS百科ing a=<%# Eval("a")%>&b=<%# Eval("b")%>
, not a=5&b=6
as I want.
What's wrong with how I'm doing this?
Yeah Mitch is correct, if you want another way:
CommandArgument='<%# String.Format("a={0}&b={1}",
DataBinder.Eval(Container.DataItem, "a"),
DataBinder.Eval(Container.DataItem, "b")) %>'
DataBind has to be called, or those substitutions won't happen...
<%# Eval() %>
is a databinding expression. You can't concatenate it with another string outside of the eval expression.
精彩评论