System.Web.UI.WebControls Namespace DataGrid Class
Returns a DataGridItem object that represents the selected item in the DataGrid control.
Script |
[ DataGridItem variable = ] DataGrid.SelectedItem |
This property can only be used programmatically; it cannot be set when declaring the control.
The property is read only with no default value.
Use the SelectedItem property to get a DataGridItem object that represents the selected item in the DataGrid control. This object can then be used to access the properties of the selected item.
The following example demonstrates how to programmatically set the style properties of the SelectedItem in the DataGrid control at run time.
void chgSelectedProps ( Object src, EventArgs e ) {
if ( myGrid.SelectedItem != null ) {
myGrid.SelectedItem.BackColor = System.Drawing.Color.Khaki;
myGrid.SelectedItem.ForeColor = System.Drawing.Color.Maroon;
myGrid.SelectedItem.Font-Bold = true;
}
}
Sub chgSelectedProps ( src As Object, e As EventArgs )
If Not ( myGrid.SelectedItem Is Nothing ) Then
myGrid.SelectedItem.BackColor = System.Drawing.Color.Khaki
myGrid.SelectedItem.ForeColor = System.Drawing.Color.Maroon
myGrid.SelectedItem.Font-Bold = True
End If
End Sub |
|
C# |
VB |
Show me
DataGrid Members DataGridItem