问题
I saw a lot of examples of using ListView,but couldn't found simple,understandable example of using two (or more) ItemTemplates in one ListView (if it possible).I want to define them on .aspx page or to make programmatically,and,depending on my needs choose one of them (different templates for different binding data).Any idea? Thanks.
回答1:
I hope this would help you achieve what you want? http://blogs.msdn.com/b/mikeormond/archive/2008/07/26/dynamically-loading-listview-templates.aspx
Also go through this post to have some insight as well http://forums.asp.net/t/1699218.aspx/1?ListView+ItemCommand+event+not+working+with+Dynamic+Templates
回答2:
You can make one <ItemTemplate>
with several panels inside, and then in code beind you make only one of them visible.
来源:https://stackoverflow.com/questions/12772558/several-itemtemplate-in-one-listview