Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Trying to exit Update Command if value not valid

Author  Topic 

bubberz
Constraint Violating Yak Guru

289 Posts

Posted - 2007-01-31 : 14:09:25
Here's my code, but it's not getting caught:

If Len(Trim(txtASBRes.Text)) > 0 And InStr(txtASBRes.Text, "|") = 0 Then

'Means there are characters for the Resource code
' and no pipecleaner = didn't use ddl for name
lblResCodeWarn.Visible = True
lblResCodeWarn.Text = "* Use list!"
Exit Sub
End If

If the user just types something in and doesn't use the autosuggest text box, then I want to tell them via a warning they need to use the values from the dropdown list. The above code isn't getting caught though.

Any suggestions are welcome!

Thanks!

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-01-31 : 14:15:23
We don't know in which event this code is run...


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

bubberz
Constraint Violating Yak Guru

289 Posts

Posted - 2007-01-31 : 14:29:58
It's my datagrid update command.

If the user tries to update a name, and doesn't use the autosuggest text box's dropdown list, then I wanna exit the sub and display the error message.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-01-31 : 14:36:47
And txtASBRes is the autosuggest textbox?


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

bubberz
Constraint Violating Yak Guru

289 Posts

Posted - 2007-01-31 : 14:41:51
yes
Go to Top of Page

bubberz
Constraint Violating Yak Guru

289 Posts

Posted - 2007-01-31 : 15:58:12
Peso,

Thanks for your patience and help!

I wasn't handling my control structure correctly.

If there was no "|", I wasn't handling it properly when I ran a database query to make sure the user didn't select a name, then try to edit it on the fly.

So, I needed to say if there's no "|" and the len() > 0, then "NO WAY" & exit the sub

else

if there is a "|" and the len() > 0, then do the db check.

Sorry for the confusion!
Go to Top of Page
   

- Advertisement -