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