开发者

how to databind a datalist's page index to a button's commandname?

i got this inside a button inside a datalist

CommandName="<%# Container.ItemIndex %>"

when i click the button, i'm expecting commandname to = 0, then 1, then 2, etc, as the datalist progresses, and i'm using that value in the button click's c#

but i'm getting this error, i'm pretty sure i'm using this exact setup on another page and i have no problems, any idea what's going on?

Server Error in '/' Application. Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific err开发者_StackOverflow社区or details and modify your source code appropriately.

Compiler Error Message: CS0117: 'System.Web.UI.Control' does not contain a definition for 'ItemIndex'


figured out this will work for some reason, posting for future searchers

CommandName='<%# DataBinder.Eval(Container,"ItemIndex")  %>'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜