开发者

Databinding Container documentation

开发者 https://www.devze.com 2023-01-10 07:03 出处:网络
I usually use expressions like this 开发者_运维百科CommandArgument=\'<%# Container.DataItemIndex.ToString() %> \'

I usually use expressions like this

开发者_运维百科
CommandArgument='<%# Container.DataItemIndex.ToString() %> '

But I could not find Container in the msdn, can u help?

Thanks


Container is a keyword that is only applicable to data binding expressions and is a reference to the naming container.

See this from MSDN (How to: Access Members of a Control's Naming Container):

In the data-binding expression, use the Container keyword, which returns a reference to the container.

And this (Using the NamingContainer Property to Determine a Control's Naming Container):

... the Container keyword, which is available only in inline code (that is, in a declarative <%# %> expression) ...


Container is usually represented by an object implementing the INamingContainer interface. However, this is not a strict rule. You can read about this in the MSDN:

http://msdn.microsoft.com/en-us/library/bda9bbfx(VS.71).aspx

If you want to know the type of the Container object, I would suggest that you use the following approach:

define the following binding expression:

CommandArgument='<%# GetCommandArgument(Container)%> 

and also define the following method in the page's code:

protected string GetCommandArgument(object container)  {
  return string.Empty;
}

Set the breakpoint in the page's method and check the container's type in the QuickWatch. Hope, this helps...

0

精彩评论

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