In the DataGrid control, the data is typically displayed in a bound column or template column.
You typically want to get data for a column of a data item when you are writing a method of handling the event for the DataGrid control (the control named DG1).
In addition to the Selectedinexchanged event, the parameter E of the processing method for the other events is an instance of the DataGridCommandEventArgs class. With the E instance, you can get the data in the data item that raised the event.
1. Get the data in the bound column
1 is not in edit state, or the data item is in edit state but the bound column is read-only
e.item.cells[column index]. Text
2) in Edit state
Bound columns appear as TextBox controls if they are in edit mode
((TextBox) (e.item.cells[column index). Controls[0]). Text
2. Get the data in the stencil column
You can place one or more controls in a template column (right-click the Edit Template menu), which can bind data in the data source
To get data bound to a control on a template column, first know the ID of the control, and then obtain a reference to the control by using the FindControl method.
(control type) (e.item.cells[column index). FindControl ("Control ID")). Properties of the control
Eg: (CheckBox) (E.item.cells[3]. FindControl ("Cbsex")). Checked