Changing Output with the ItemCreated Event Using the DataGrid and DataList
You might want to alter the way an item is rendered based on certain criteria, using either the DataGrid or DataList controls. For example, you might have a DataGrid which displays accounting information and you want negative numbers to be red instead of black. You can use the ItemCreated event to accomplish this. This event is fired every time an item is created for either control. Listing 10.4 illustrates how to use this feature in the DataGrid.
Listing 10.4. Using the ItemCreated Event with the DataGrid
[Visual Basic] 01: <%@ import namespace="System.Data" %> 02: <%@ import namespace="System.Data.SqlClient" %> 03: <script language="c#" runat="server"> 04: private string ... |
Get Programming Data-Driven Web Applications with ASP.NET now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.