Nice Clean Example

ASP.NET

These examples are specific to Web programming with ASP.NET

 
AutoPostBack on Treeview Checkboxes
The Treeview Control lets you add checkboxes to nodes. However, it doesn't let you auto post back when they are checked. This sample shows how to do that.
Gridview Sorting
The Gridview Control has support for sorting rows, although it does not actually sort the data. Instead it can tell the code which column the user wants to sort and provides display help.
Built-in Gridview Editing
The GridView control has built-in capabilities for editing data within a row, although the support is weighted towards using a SQL or objectdatasource. This example demonstrates the essential components for this row editing technique without using a datasource.
Using AJAX for a checkbox in a GridView
This sample demonstrates the use of AJAX for a common task -- setting or clearing a checkbox field in a gridview without having to go through an entire edit/page refresh cycle. There is an excellant row editing capability for the GridView,but when you just want to set or clear a flag you don't want a lot of clicks to do that. This sample does not use AJAX.NET -- its a direct call. There is a lot of promise in using AJAX.NET for doing complex operations. Its a classic "big Microsoft technology" (I mean that in a good way). However, I found that I couldn't use it for this simple task because of an odd technical limitation.
Gridview Delete Confirmation through Command processing
This sample shows how to add confirmation of a delete in a GridView by using the built-in Command Processing. It adds a command handler for the GridView and uses the OnClientClick attribute of the LinkButton to confirm the delete operation.
Delete Confirm Processing for the GridView Control
The default processing for Delete in the GridView control doesn't offer a built-in chance to confirm the operation with JavaScript first. There are a variety of techniques for adding confirmation processing. This technique uses a normal Anchor tag with javascript to call a function to confirm. Then it uses a hidden field to store the value back into the server. Finally, it calls the submit() function for the primary form, which will preserve ASP.NET viewstate. An advantage of this technique is that there is no setup required for the GridView.
Using a GridView Control like a Spreadsheet
This sample demonstrates how you can use the GridView control like a spreadsheet to edit multiple rows and columns at once. While the GridView has built-in editing on a per-row basis, this sample shows how to create Excel like functionality
Create a CSV download from a DataTable with GZIP compression
Downloading a CSV file from a web site is a very common chore in web site work. If you have the data in a DataTable its a snap. This sample shows the proper MIME type headers, creation of the CSV, and even throws in GZIP compression as an option for good measure.
Adding a column of radio boxes to a Gridview control
The GridView control, while very nice, has a limitation that many people find soon after digging in -- you can't create a column that has radio boxes in it that work as you expect. The issue is technical and has to do with the way that ID values are generated. Fortunately its not hard to work around, but it does require some hand-coding.
Using a dynamic control on an ASP.NET site
While most applications are served well with statically defined .NET Web controls, it can be very powerful to dynamically create a textbox, checkbox or other .NET control. This gives you the ability to generate a page completely from a data definition of some sort. The trick with dynamic controls is that you define and add them in the OnInit routine, as the sample demonstrates.
1 2