asp.net.ph

DataGrid.SelectedItem Property

System.Web.UI.WebControls Namespace   DataGrid Class


Returns a DataGridItem object that represents the selected item in the DataGrid control.

Syntax


Script [ DataGridItem variable = ] DataGrid.SelectedItem

This property can only be used programmatically; it cannot be set when declaring the control.

Property Value


variable A DataGridItem object that represents the selected item in the DataGrid control.

The property is read only with no default value.

Remarks

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.

Example

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;
   }
}
  C# VB

 Show me 

See Also

DataGrid Members   DataGridItem Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph