asp.net.ph

FormView.ChangeMode Method

System.Web.UI.WebControls Namespace   FormView Class


.NET Framework version 2.0

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

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

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

public: void ChangeMode (
   FormViewMode* newMode
);

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

Parameters

newMode
One of the FormViewMode enumeration values.

Remarks

Use the ChangeMode method to programmatically switch the FormView 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
FormViewMode.Edit The FormView control is in edit mode, which allows the user to update the values of a record.
FormViewMode.Insert The FormView control is in insert mode, which allows the user to add a new record to the data source.
FormView.ReadOnly The FormView 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 FormView control to read-only mode whenever the user navigates to another record.

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

<script runat = "server">

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

</script>
  C# VB

See Also

FormView Members   FormViewMode 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