我尝试像这样传递Eval值但得到语法错误:
<asp:ImageButton ID="btnOK" OnClientClick='Show("<%#Eval("Title")%>");return false;' runat="server" ImageUrl="Images/icon.gif" />
试试这个。
<asp:ImageButton ID="btnOK" OnClientClick='<%# Eval("Title", "Show({0});return false;") %>' runat="server" ImageUrl="Images/icon.gif" />
OnClientClick='<%#String.Format("Show('{0}');return false;",Eval("title"))%>'
或者如果在设计视图中执行此操作,只需为imagebutton的onClientClick属性添加数据绑定即可
String.Format("Show('{0}');return false;",Eval("title"))
希望它能帮助你。