In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "the file output stream mode of GridView control in ASP.NET". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "the file output stream mode of the GridView control in ASP.NET".
ASP.NET provides a variety of data server controls for displaying table data in a database in a Web page, and the GridView control is one of them. This control is almost the same as the DataGridView control we have learned before, so we are no stranger to the GridView control.
The first step: set up the Columns column you need for gridview and bind the data. The data of my first column is because the format of "day, month, year, hour, minute and second" is saved in the database. When I export it, I add a dataformatstring value "{0:yyyy-MM-dd}", the format of year, month and day, so that the output time format is 2016-08-07, which looks better.
Step 2: bind the data, write the query method, then bind your query method directly to DataSource, and then
Bind your gridview so that you have the value you need
Step 3:
Except for the for loop part, the rest is fine according to me. Mine is the file output of adding nodes. If you just want to output all the data displayed by your grdview, you can just write the code that circulates your gridview data source, plus a loop j, the stringBuilder that I use here, data splicing, a column that shows what I need.
Step 4: set a button click event in the page, call this method, and the file will be generated automatically. According to the date, the code generated by the date is: Response.AddHeader (@ "Content-Disposition", "attachment; filename=" + DateTime.Now.ToString ("_ yyyyMMdd_HHmmss") + ".txt"); you can also modify its splicing format.
At this point, I believe that you have a deeper understanding of the file output stream mode of the GridView control in ASP.NET, so you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.