asp.net listview Container.DataItemIndex

asp.net, listview

Solution

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.

Problem

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' 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?) What is the correct method to pass the commandarguments? This button is inside and updatepanel in the itemtemplate of a listview. Thanks, Ali

Original source