In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces how to bind ListView controls in Visual Studio 2008. It is very detailed and has a certain reference value. Interested friends must finish reading it!
ListView is a new control in Visual Studio 2008. Using this control, you can easily insert, edit, delete and sort data. You can also flexibly display data in various formats through user-defined templates when using this control.
The following steps are how to bind ListView to a SQLDataSource (sql data source):
1. Add a Listview control from the data label of the toolbox, and Visual Studio will generate the code shown in the following figure
2. Bind a SQLDataSource for this control, where we copy a NorthWind.mdf database to the App_Data folder of the website project.
3. Configuring the SQLDataSource to use the "categories" table will generate the following code:
< span style="color: #800000;"> < /span>ID= "ListView1" runat= "server" DataSourceID= "SqlDataSource1" >
< span style="color: #800000;"> < /span>ID= "SqlDataSource1" runat= "server" ConnectionString= "SelectCommand=" SELECT * FROM [Categories] ">
4. Open the smart tag of the LIstview control, and select "configure ListView" to open the "configure ListView" dialog box.
5. In this configuration dialog box, you can select the layout and predefined styles, such as "grid" and "Professional". If you want to page, you can select the "start paging" option.
6. The following code will be generated in the source code view:
< span style="color: #800000;"> < /span> < table id="Table1" border="0"> < tbody> < tr id="Tr1"> < td id="Td1"> < table id="itemPlaceholderContainer" style="background-color: #FFFFFF;border-collapse: collapse;" border="1"> < tbody> < tr id="Tr2" style="background-color:#DCDCDC;color: #000000;"> < th id="Th2">CategoryID
< /th> < th id="Th3">CategoryName
< /th> < th id="Th4">Description
< /th> < th id="Th5">Picture
< /th> < /tr> < tr id="itemPlaceholder"> < /tr> < /tbody> < /table> < /td> < /tr> < tr id="Tr3"> < td id="Td2" style="text-align: center;background-color: #CCCCCC;font-family: Verdana, Helvetica,#000000;"> < strong> < span style="color: #800000;"> < /span> < /strong>ID= "DataPager1" runat= "server" >
< strong> < /strong> < /td> < /tr> < /tbody> < /table>View plaincopy to clipboardprint?
< span style="color: #800000;"> < /span>7. Run this page and a paged (data display) page will be displayed.
This is just a very simple example of listview binding.
The ListView control is a control in net Framework3.5, and if your project is based on net Framework2.0 or 3.0, you can't see it in the toolbox. This control and the Gridview control are the most common data controls in Asp.net. It has an advantage in displaying less complex data, and is even more flexible than Gridview, unlike Gridview, which uses user-defined templates instead of row fields to display data.
Personally, I think we should make good use of ListView, but now the developers of Asp.net have a tendency to abuse GridView.
These are all the contents of the article "how to bind ListView controls in Visual Studio 2008". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.