Hi this is my row in gridview in ASP.Net
<ItemTemplate>
<a id="aOpen" onclick="javascript:Open(<%#((DataRowView)Container.DataItem)['DocTypeCode'] %>)" >A_<%#((DataRowView)Container.DataItem)["Id"] %></a>
</ItemTemplate>
Here is my javascript
<script type="text/javascript">
function Open(var id) {
var strPageURL = '<%= ResolveClientUrl("~/View.aspx?id="+id) %>';
OpenCustomDialogWithRefresh(strPageURL, 750, 500, "View Document Type");
return true;
}
</script>
I would like to pass the Id value from the gridview to the javascript and open a new page with query string. How should I try ? Mine does not work.
I think you want simply:
<%# Eval("DocTypeCode") %>
onclick='javascript:Open(<%# Eval("DocTypeCode") %>)" >A_<%# Eval("Id") %></a>
Also note that this
<a id="aOpen"
is a huge problem, since all dom elements must have unique ids
I think you should try this below code:
onclick="javascript:Open('<%#Eval("DocTypeCode") %>')"
is a syntax problem, I should add the character ''
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.