asp.net的ListView Container.DataItemIndex [英] asp.net listview Container.DataItemIndex

查看:550
本文介绍了asp.net的ListView Container.DataItemIndex的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过commandarguments像

I am trying to pass commandarguments like

<asp:Button ID="btnSave" runat="server" Text="Save" CommandName='<%# Eval("Section_Name")%>' CommandArgument='<%# Container.DataItemIndex %>' />

但我得到这个错误:

but I get this error:

System.Web.UI.Control并不包含DataItemIndex',没有扩展方法'DataItemIndex接受型System.Web.UI.Control的第一个参数的定义可以找到(是否缺少使用指令或程序集引用?)

'System.Web.UI.Control' does not contain a definition for 'DataItemIndex' and no extension method 'DataItemIndex' accepting a first argument of type 'System.Web.UI.Control' could be found (are you missing a using directive or an assembly reference?)

什么是传递commandarguments正确的方法?
此按钮内的UpdatePanel在ListView的ItemTemplate中。

What is the correct method to pass the commandarguments? This button is inside and updatepanel in the itemtemplate of a listview.

谢谢,阿里

推荐答案

非常感谢DavidGouge和Jason Berkan。
我做了它的工作用

Thanks a lot DavidGouge and Jason Berkan. I made it working using

CommandArgument='<%#DataBinder.Eval(Container, "DataItemIndex")%>'

不过,我认为两者的建议也应该工作。

However, I think both of the suggestions should also work.

这篇关于asp.net的ListView Container.DataItemIndex的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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