Protected Sub DetailsView1_ItemUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewUpdateEventArgs) Handles DetailsView1.ItemUpdating
'Making a DetailsView field read only will prevent the user from changing it.
'This code will make sure that any such fields get passed during the database update.
For Each DetailsViewDataControlField As DataControlField In sender.Fields
If TypeOf DetailsViewDataControlField Is BoundField Then
Dim DetailsViewBoundField As BoundField = DetailsViewDataControlField
Dim FieldName As String = DetailsViewBoundField.DataField
If DetailsViewBoundField.ReadOnly = True Then
e.NewValues.Item(FieldName) = e.OldValues.Item(FieldName)
End If
End If
Next
End Sub
Tips and tricks for .NET using ASP and VB code.
Make sure read-only DetailsView fields get passed to database
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment