How do I check if a Name Value pair exists in my NVCollection?

J

JDP@Work

I have an NV container located in a webMethod that does a data mapping then a
data insert.

Some of my web forms that use this method may not have a txtExistInsur text box
and therefore won't have an NV pair.

I get a runtime error if the NV pair does not exist, so How do I check?

I tried....

If Not objNVContainer.colNVPairs.Item("txtExistInsur") Is Nothing Then...
Runtime error....


TIA

JeffP....
 
J

JDP@Work

-- Solution, with snipits....

I added a Public function to my NameValue WebService...
----------------------------------------------------
Public Function doEyeBe(ByVal cItemName As String) As Boolean
Try
If Not colNVPairs(cItemName) Is Nothing Then doEyeBe = True
Catch
doEyeBe = False
End Try
End Function

Then in the code behind in the page....
----------------------------------------------------
Dim ExistInsur As String

If objNVContainer.doEyeBe("txtExistInsur") Then
ExistInsur =
objNVContainer.colNVPairs.Item("txtExistInsur").Value
Else : ExistInsur = ""
End If


Thanks to all who poasted...

JeffP.....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top