Simon Cripps
asked on
Details view validation
Hi, I am looking to validate a detailsview as I select update.
I will be looking to check for null values, and checking some feild dependant on values on other field.
I have got my start off code attached but did not get far as it did not understand that I was trying to check if the field was blank and also id not recognize that I was trying to cancel the command if this was blank.
Any suggestions or examples you may have, would be most welcome.
I will be looking to check for null values, and checking some feild dependant on values on other field.
I have got my start off code attached but did not get far as it did not understand that I was trying to check if the field was blank and also id not recognize that I was trying to cancel the command if this was blank.
Any suggestions or examples you may have, would be most welcome.
Sub CustomerDetailView_ItemCommand(ByVal sender As Object, ByVal e As DetailsViewCommandEventArgs)
Select Case e.CommandName
Case "Cancel"
Case "Update"
If DetailsView1.DataItem("VCDescription") = "" Then
'cancel this command
DetailsView1.DataItem("VCDescription") = "dfgdsf"
End If
Case "Insert"
Case Else
End Select
End Sub
ASKER
I'll be doing serveal check on the events.
the 2 bits in here I can't understand are
1) defining the content of the text field
If DetailsView1.DataItem("VCD escription ") = "" Then
Does not work
2) Placing e.Cancel into the code above does not work as I get the responce
cancel is not a member of System.Web.UI.WebControls. DetailsVie wCommandEv entArgs
If I clear these two I should be able to push on.
Cheers
the 2 bits in here I can't understand are
1) defining the content of the text field
If DetailsView1.DataItem("VCD
Does not work
2) Placing e.Cancel into the code above does not work as I get the responce
cancel is not a member of System.Web.UI.WebControls.
If I clear these two I should be able to push on.
Cheers
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for your patience, I am now doing it with control values and works well.
Thanks
Thanks
In that case you can use Validator controls in the markup itself.
For checking within the event, you can use individual events like:
ItemUpdating and there you do a e.Cancel=true to cancel the event if validation fails.