asp.net.ph

DetailsView.ChangeMode Method

System.Web.UI.WebControls Namespace   DetailsView Class


.NET Framework version 2.0

Switches the DetailsView control to the specified data-entry mode.

[ VB ]
Public Sub ChangeMode ( _
   ByVal newMode As DetailsViewMode _
)

[ C# ]
public void ChangeMode (
   DetailsViewMode newMode
);

public: void ChangeMode (
   DetailsViewMode* newMode
);

[ JScript ]
public function ChangeMode (
   newMode : DetailsViewMode
);

Parameters

newMode
One of the DetailsViewMode enumeration values.

Remarks

Use the ChangeMode method to programmatically switch the DetailsView control between edit, insert, and read-only modes. This method also updates the CurrentMode property with the specified mode. The following table lists the different mode values.

Mode Description
DetailsViewMode.Edit The DetailsView control is in edit mode, which allows the user to update the values of a record.
DetailsViewMode.Insert The DetailsView control is in insert mode, which allows the user to add a new record to the data source.
DetailsView.ReadOnly The DetailsView control is in read-only mode, which is the normal display mode.

NOTE: The ModeChanged and ModeChanging events are not raised when this method is called.

Example

The following example demonstrates how to use the ChangeMode method to return the DetailsView control to read-only mode whenever the user navigates to another record.

<%@ Page language = "C#" %>

<script runat = "server">

   void EmployeeDetailsView_PageIndexChanged ( Object src, EventArgs e ) {
      // By default, if the DetailsView control is in edit mode and
      // the user navigates to another page, the DetailsView control
      // remains in edit mode. In this example, the ChangeMode 
      // method is used to return the DetailsView control to read-only  
      // mode whenever the user navigates to another record.
      EmployeeDetailsView.ChangeMode ( DetailsViewMode.ReadOnly );
   }

</script>
  C# VB

See Also

DetailsView Members   DetailsViewMode Enumeration   CurrentMode   DefaultMode 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