Asp. net has a Table and a GridView space to display multiple pieces of data, and most of the data used to bind a dataset uses the GridView, but the template definition of the GridView is a little troublesome and I think it is not good in performance, although it is mainly the data source query method, this time I recorded not the query method, but used ListView for template definition and Data Source binding.
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.