为什么要作为字符串文字传递Container.DataItem? [英] Why is Container.DataItem being passed as a string literal?

查看:228
本文介绍了为什么要作为字符串文字传递Container.DataItem?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从LinkBut​​ton的OnClientClick事件传递一个字符串值到JavaScript函数,但该函数正在接收<%#Container.DataItem%>而不是该值。这是代码:

I'm trying to pass a string value to a javascript function from a LinkButton's OnClientClick event, but the function is receiving "<%# Container.DataItem %>" instead of the value. Here's the code:

OnClientClick="javascript:SaveQuotaGroupCode('<%# Container.DataItem %>');"

容器是字符串的集合。为什么不评估?

The container is a collection of strings. Why is it not evaluating?

编辑:这是一个嵌套的ListView。内部ListView的数据源是外部ListView的数据源中的一个属性。

This is located in a nested ListView. The datasource for the inner ListView is a property in the datasource of the outer ListView.

推荐答案

OnClientClick = javascript:SaveQuotaGroupCode('<%#Eval(YourProperty)%>');

被转换为逗号分隔的值列表,因为这是JavaScript函数的签名所期望的...

Also, the collection should be transformed into a comma separated list of values as that is what the signature of the Javascript function expects...

这篇关于为什么要作为字符串文字传递Container.DataItem?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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