.NET news » Examples
Design Patterns - nuff said !
Displaying Files and Folders in a GridView
The .NET Framework provides a variety of classes in the
System.IO namespace that
simplify working with the file system. Using these classes it's possible to delete files and folders, to create new files, to edit existing files, and more. These
classes, combined with ASP.NET's suite of Web controls and databinding syntax, make it quite easy to present information about the files on the web server's file system
to visitors to your website. With a bit of markup and code, it's possible to add a simple file browser to a web page that allows users to view the files and folders from
a particular directory on the web server. Such file browsers are useful if you let users upload content to the website and need to let them view their uploaded content.
If you have a folder that contains user-accessible content like images, PDF files and Word documents, a file browser offers a quick and easy way for users to see what
content is available and to view content of interest.
Back in 2003 I wrote an article titled Displaying the Files in a Directory using a DataGrid that showed how to list the files of a particular folder in a DataGrid Web control. This dated article still attracts a decent amount of traffic and questions from readers, so much so that I thought it worthwhile to update the content to use the latest technology, namely ASP.NET 4 and the GridView Web control. I also added some new features. For example, the file browser now lists both files and folders, allowing users to view the files in subfolders. Also, I moved the markup and code into a User Control, which simplifies adding the file browser to an ASP.NET page. This article walks through this new, updated version; the complete, working code is available for download at the end of this article.
Dynamically Loading Silverlight Video Players using MEF
The Baker’s Dozen: 13 More Examples of Functionality in SQL Server 2008 Integration Services
In the last Baker’s Dozen article, I demonstrated 13 SSIS packages to show what Integration Services can do. This article picks up where the last one left off. I’ll show some capabilities in SSIS, such as handling irregular input files, extracting database changes, implementing package configurations, and leveraging the advanced lookup features in SSIS 2008.
Generic Alert Handler - A Practical Example on Multithreading
Develop your own language translation system
Filtering Data Using ASP.NET 4's QueryExtender Control
One of the new controls available with ASP.NET 4 is the QueryExtender control. The QueryExtender is designed to simplify filtering data returned from a LinqDataSource or EntityDataSource by decoupling the filtering logic from the data source control. Using the QueryExtender is easy - simply add a QueryExtender to the page, specify what data source control it applies to, and then define the filtering criteria. For example, when displaying product information on a web page you could use the QueryExtender control and a few lines of markup to display only those products that are not within a certain price range and whose name or category starts with a user-specified search string.
Filtering the data returned by a LinqDataSource or EntityDataSource control is certainly possible without the QueryExtender; both the LinqDataSource and EntityDataSource
controls have a
Where property that can be used to specify filtering criteria. What the QueryExtender offers is a simpler means by which to filter data.
This article includes a number of demos (which can be downloaded at the end of this article) that showcase the QueryExtender's ease of use and its powerful filtering
Font Survey: 42 of the Best Monospaced Programming Fonts
Defining Descriptive Text for Enumeration Members
An enumeration is a special type in the .NET Framework that is comprised of a number of named constants.
While you might not have created an enumeration type yourself, you have likely used enumerations many times in day-to-day programming. For example, the rows in a
GridView have a
RowType property that returns an
enumeration of type
indicates the row's type:
DataRow, and so on.
When working with an enumeration we may need to display a descriptive message based on the enumeration's value. For example, using ASP.NET's
Membership system you can programmatically create a new user account calling the
CreateUser method. This method specifies the success or failure of the
operation via the
This enumeration has members like
DuplicateUserName, and the like. When
calling this method from an ASP.NET page you might want to show the user a descriptive message based on this enumeration value.
This article explores three different ways to provide descriptive text for enumeration members.