In the WPF behind Microsoft, ListView is a convenient control. I used many template definitions in the later WPF development, including ListBox, GridView, and ListView. In short, ListView has its own merits, however, ListView uses more. Because the ListView style is quite beautiful, I am a visual system and a little lazy, so I only use the default style to define the template, so I chose ListView for a lot of things, run the code directly. In fact, there is nothing to say. If you do more, you will naturally understand the meaning.
| The code is as follows: |
Copy code |
<Asp: ListView ID = "lv_ProjectItems" runat = "server"> <LayoutTemplate> <Ul id = "biaoge" style = "list-style: none"> <Ol> Currently, all unfinished projects </ol> <Asp: PlaceHolder ID = "itemPlaceholder" runat = "server"/> </Ul> </LayoutTemplate> <ItemTemplate> <Ol onmouseover = "this. style. backgroundColor = '# ebeff9';" onmouseout = "this. style. backgroundColor =''; "> <A href = "../Search/ProjectInfo. aspx? ProjectID = <% # Eval ("ID") %> & action = end "target =" _ blank "> <Li> <span style = "display: block; width: 150px; float: left"> [<% # Eval ("ProjectID ") %>] </span> <% # Eval ("ProjectName") %> </li> </a> </Ol> </ItemTemplate> </Asp: ListView>
|
The preceding <% # Eval ("ID") %> and <% # Eval ("ProjectID") %> and <% # Eval ("ProjectName ") %> indicates that the fields "ID", "ProjectID", and "ProjectName" are bound to the current position in the result set.
| The code is as follows: |
Copy code |
Lv_ProjectItems.DataSource = items. OrderByDescending (t => t. ID ); Lv_ProjectItems.DataBind (); |
Conclusion: the binding method is the same for other controls. If you are interested, you can try other controls.