将gridview列作为javascript参数传递 [英] Passing gridview columns as a parameter of a javascript

查看:82
本文介绍了将gridview列作为javascript参数传递的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<asp:ImageButton ID="ibnEdit" runat="server" ImageUrl="~/Common/Images/edit-icon.png"                                   ToolTip="Click here to edit the details" 

OnClientClick="javascript:return EditCategory(('<%#DataBinder.Eval(Container.DataItem,"ID")%>');" />




我收到一个错误服务器标签格式不正确".任何人对此都有一个想法.




I got an error ''server tag is not well formed''. Any one have an idea about this.

推荐答案

OnClientClick="javascript:return EditCategory((''<%#DataBinder.Eval(Container.DataItem,"ID")%>'');" />



ID前面的双引号被中断,作为OnClientClick属性的结束引号.

试试这个



The double quote in front of ID is being interrupted as the ending quote of the OnClientClick property.

Try this

OnClientClick=''<%# DataBinder.Eval(Container.DataItem, "ID", "javascript:return EditCategory(\"{0}\");")%> '' />


请尝试以下代码.我认为这会起作用.就我而言,这是可行的.将其放在网格的项目模板中.


Please try this code. I think this will work. This is working in my case. Put this in the item template of the grid.


<asp:ImageButton ID="ibtnEdit" runat="server" CommandArgument=''<%# DataBinder.Eval(Container.DataItem,"ID")%>''
 OnCommand="ibtnEdit_Command" 
 Style="cursor: hand;" 
OnClientClick=''<%# " return EditCategory("+ DataBinder.Eval(Container.DataItem,"ID") + ");" %>'' />


这篇关于将gridview列作为javascript参数传递的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆