In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article shows you the hidden trouble analysis of ASP.NET virtual host when creating data source, the content is concise and easy to understand, it can definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
What are the hidden dangers of ASP.NET virtual hosts when creating data sources? First, let's look at the code that creates the data source (the code is in the listdrivers.aspx.cs file):
/ / return a data view in the form of a collection DataView ICollection CreateDataSource () {/ / define a data table in memory DataTable DataTable dt = new DataTable (); / / define a row of data in DataTable DataRow DataRow dr; / * add a column to DataTable, format: DataColumn ("Column", type) Column is the name of the data column, type is the data type of the data column * / dt.Columns.Add ("ID", typeof (Int32)) Dt.Columns.Add (new DataColumn ("drivers", typeof (string)); dt.Columns.Add (new DataColumn ("detail", typeof (string); / / use the for loop to add the name of the logical drive as a row to the data table DataTable for (int I = 0; I < nNumOfDrives; iDrive +) {/ / define the new line dr = dt.NewRow () / assign each column in a pair of rows, note that dr [0] = I corresponding to the row of DataTable defined above; / / cycle generated sequence number dr [1] = achDrives [I] .ToString (); / / name of logical drive dr [2] = "View details"; / / add row dt.Rows.Add (dr) to DataTable;} / generate custom view DataView DataView dv = new DataView (dt) based on the resulting DataTable / / return the resulting view DataView return dv;}
In this way, we get a data View DataView that contains all the data we need. We just need to bind this data View to DataGrid in the Page_Load method of this aspx page.
The data binding code of the ASP.NET virtual host when creating the data source (the code is in the listdrivers.aspx.cs file):
/ * set the data source DataSource of DataGrid to the data view DataView * / DriversGrid.DataSource = CreateDataSource () obtained from the CreateDataSource () method; / / bind this DataGrid to DriversGrid.DataBind ()
Through the main methods described above, we have achieved the function of obtaining system information and displaying all logical drive names, and you can go to the next program listdir.aspx that displays directory and file names through the corresponding link to display all directories and files under the logical drive.
The above is the hidden trouble analysis of the ASP.NET virtual host when creating the data source. Have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are 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: 209
*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.