GridView and Eval
I am trying to pass a value through Eval in my GridView, but instead of passing the actual value, it passes the string '<%# Eval etc...This is my code, can anybody advise?
enter code here<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="btnUplo开发者_运维问答ad" OnClientClick="loadDialog('<%# Eval(PK_SpecialEvent).ToString() %>') " Text="Upload/Open Files" runat="server" />
</ItemTemplate>
</asp:TemplateField>
Try this:
OnClientClick='<%# Eval("PK_SpecialEvent", "loadDialog(\"{0}\");") %>'
Another, more readable, way is to do this in codebehind. A good place would be in GridView's RowDataBound Event.
I've only done a GridView once before in my so-far beginners experience of ASP.NET, but should the:-
Eval(PK_SpecialEvent).ToString()
have quotes added in to become like:
Eval("PK_SpecialEvent").ToString()
At least - it does in my working code of a GridView.
精彩评论