Selecting a Row

Up until now, the Select column in the grid hasn't done anything useful. You might want to allow users to select a row and display information about the selected row. For example, you might want to display the category name associated with the selected item in the grid. Displaying this information requires a little bit of code, as you might imagine.

Actually, selecting an item in the DataGrid control takes no code at all—simply clicking the Select link highlights the row for you, based on the formatting you applied to the grid. Retrieving the information, however, requires that you react to the ItemCommand event of the grid. Clicking any link on the DataGrid control filters through the same event procedure: grdCatSales_ItemCommand ...

Get ASP.NET Developer's JumpStart 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.