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
);
- newMode
- One of the FormViewMode enumeration values.
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.
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>
<%@ Page language = "VB" %>
<script runat = "server">
Sub EmployeeFormView_PageIndexChanged ( ByVal src As Object, ByVal e As EventArgs )
' 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 )
End Sub
</script> |
|
C# |
VB |
FormView Members FormViewMode Enumeration CurrentMode DefaultMode