February 24, 2003

Showing a graphical checkmark on DataGrid’s boolean columns

While working with template-based controls such as the Repeater, DataList or DataGrid, it often happens that you don’t want to show just plain text as it is retrieved from the data source, but want to interpret the data and represent it in other ways. For example, you may want to

Implementing a two-way sorting for the DataGrid control

DataGrid’s sorting functionality is not automatic, the control takes care of “just” rendering the column headers as hyperlinks, and gives you the ability to handle the click on those links, by means of the SortCommand event. Then you manually sort the records (by means of a new DataView from an

Adding a confirmation popup for delete buttons defined within templates

The DataList and DataGrid controls easily allow to add a “Delete” button/hyperlink in your template. When clicked, this button/link raises a DeleteCommand event that you can handle to delete the data item of the parent DataList’s/DataGrid’s row. Here’s an example that shows how to declare two column in a DataGrid,

Hiding controls defined within templates to some users

It happens frequently that you want to hide some input controls or links if the current user is not logged in (it runs with the anonymous account), or if the logged user is not a member of a specific group. For example, you may want to hide the Edit/Delete buttons