asp.net.ph

GridView.SelectedRow Property

System.Web.UI.WebControls Namespace   GridView Class


.NET Framework version 2.0

Returns a GridViewRow object that represents the selected row in the GridView control.

Syntax


Script [ GridViewRow variable = ] GridView.SelectedRow

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

Property Value


variable A GridViewRow object that represents the selected row in the GridView control.

The property is read only with no default value.

Remarks

Use the SelectedRow property to get a GridViewRow object that represents the selected row in the GridView control. This object can then be used to access the properties of the selected row.

Example

The following example demonstrates how to programmatically set the style properties of the SelectedRow in the GridView control at run time.

void chgSelectedProps ( Object src, EventArgs e ) { 
   if ( myGrid.SelectedRow != null ) {
      myGrid.SelectedRow.BackColor = System.Drawing.Color.Khaki;
      myGrid.SelectedRow.ForeColor = System.Drawing.Color.Maroon;
      myGrid.SelectedRow.Font-Bold = true;
   }
}
  C# VB
Run Sample | View Source
See Also

GridViewRow   SelectedDataKey   SelectedIndex   Allowing Users to Select Rows in a GridView Control Skip Navigation Links




Previous page Back to top Next page

Check out related books at Amazon

© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

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