Trying to make a group of fields required on combobox selection in Access 2010 - ms-access-2010

In Access 2010.
I have 3 separate groups of fields that can be active based on a combobox selection but I'm trying to get them to be required as well. I've looked everywhere but it doesn't appear to be any VB code to make a field required. Is there anyway I can accomplish this?
The code I have right now to make the selected group of fields active and make the one's not selected blank:
Private Sub Combo109_Click()
If Combo109 = "Germ" Then
cg_moisture.Enabled = True
cg_oil_nir.Enabled = True
extraneous_material.Enabled = True
fines.Enabled = True
cg_moisture.Enabled = True
cg_oil_nir.Enabled = True
extraneous_material.Enabled = True
fines.Enabled = True
Moist_cgm_nir.Enabled = False
prot_cgm_nir.Enabled = False
oil_cgm_nir.Enabled = False
meal_color.Enabled = False
load_out_temp.Enabled = False
moist_cgf_nir.Enabled = False
prot_cgf_nir.Enabled = False
oil_cgf_nir.Enabled = False
profat_nir.Enabled = False
starch_nir.Enabled = False
total_sug_nir.Enabled = False
loadout_temp.Enabled = False
screen_thrus.Enabled = False
screen_thrus.Value = ""
Moist_cgm_nir.Value = ""
prot_cgm_nir.Value = ""
oil_cgm_nir.Value = ""
meal_color.Value = ""
load_out_temp.Value = ""
moist_cgf_nir.Value = ""
prot_cgf_nir.Value = ""
oil_cgf_nir.Value = ""
profat_nir.Value = ""
starch_nir.Value = ""
total_sug_nir.Value = ""
loadout_temp.Value = ""
screen_thrus.Value = ""
screen_thrus.Value = ""
End If

IF all of the controls are in the 'Detail' section of your form, AND if a contrtol is Enabled, you require a value, then the code below should work. If you want more meaningful names to be displayed, either change your control names, or place a better name in the control 'Tag' field and reference that. The following code only checks Textboxes and CheckBoxes - modify to suit your needs.
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim ctl As Control
Dim blnMissing As Boolean
Dim strMissing As String
For Each ctl In Me.Section("Detail").Controls
If ctl.ControlType = acTextBox Or ctl.ControlType = acCheckBox Then
If ctl.Enabled = True Then
'Debug.Print ctl.Name & vbTab & ctl.Value
If ctl.Properties("Enabled") = True Then
If Me(ctl.Name) = "" Or IsNull(Me(ctl.Name)) Then
blnMissing = True
strMissing = strMissing & ctl.Name & "; "
End If
End If
End If
End If
Next ctl
If blnMissing = True Then
MsgBox "You are required to enter data in fields: " & strMissing, vbOKOnly + vbCritical, "Missing Required Data"
Cancel = True
End If
End Sub

Related

Gridview does not refresh display updated record

I am currently working on a project. I suddenly stumbled on a problem that really blew my brains. I have a function that displays the content of a table in a database to a gridview which I named bindGrid. It is working perfectly fine when I query 50 to 90 records. However when I query 100 records or more the gridview does not display the records until I change the value of my dropdown box that is set to autopostback.
Here is the sample of the code:
Protected Sub btnFilter_Click(sender As Object, e As EventArgs) Handles btnFilter.Click
If cboFilter.Text = "DMZ" Then
lblErrFilter.Visible = False
lblError.Visible = False
If drpYear.Text = "--Select--" Or drpMonth.Text = "--Select--" Or txtDMZ.Text = "--Select--" Or txtTop.Text = "" Then
If drpYear.Text = "--Select--" Then
lblErrYear.Visible = True
Else
lblErrYear.Visible = False
End If
If drpMonth.Text = "--Select--" Then
lblErrMonth.Visible = True
Else
lblErrMonth.Visible = False
End If
If txtDMZ.Text = "--Select--" Then
lblErrDMZ.Visible = True
Else
lblErrDMZ.Visible = False
End If
lblError.Visible = True
lblError.Text = "No value specified for the following parameter(s) *."
Else
lblErrYear.Visible = False
lblErrMonth.Visible = False
lblErrDMZ.Visible = False
Call bindData()
'If Me.IsPostBack = True Then
Call bindGrid()
'End If
'
End If
'__________________________________________________________________________
'Zone filter
ElseIf cboFilter.Text = "Zone and Book" Then
lblErrFilter.Visible = False
lblError.Visible = False
If drpYear.Text = "--Select--" Or drpMonth.Text = "--Select--" Or txtZone.Text = "--Select--" Or txtTop.Text = "" Then
If drpYear.Text = "--Select--" Then
lblErrYear.Visible = True
Else
lblErrYear.Visible = False
End If
If drpMonth.Text = "--Select--" Then
lblErrMonth.Visible = True
Else
lblErrMonth.Visible = False
End If
If txtZone.Text = "--Select--" Then
lblErrZone.Visible = True
Else
lblErrZone.Visible = False
End If
lblError.Visible = True
lblError.Text = "No value specified for the following parameter(s) *."
Else
lblErrYear.Visible = False
lblErrMonth.Visible = False
lblErrZone.Visible = False
Call bindData()
Call bindGrid()
End If
ElseIf cboFilter.Text = "Account Number" Then
If txtFrom.Visible = True And txtTo.Visible = True Then
If drpYear.Text = "--Select--" Or drpMonth.Text = "--Select--" Or txtFrom.Text = "" Or txtTo.Text = "" Then
If drpYear.Text = "--Select--" Then
lblErrYear.Visible = True
Else
lblErrYear.Visible = False
End If
If drpMonth.Text = "--Select--" Then
lblErrMonth.Visible = True
Else
lblErrMonth.Visible = False
End If
If txtFrom.Text = "" Then
lblErrR1.Visible = True
Else
lblErrR1.Visible = False
End If
If txtTo.Text = "" Then
lblErrR2.Visible = True
Else
lblErrR2.Visible = False
End If
lblError.Visible = True
lblError.Text = "No value specified for the following parameter(s) *."
Else
Call bindData()
Call bindGrid()
End If
Else
If drpYear.Text = "--Select--" Or drpMonth.Text = "--Select--" Or lstAcct.Items.Count = 0 Then
If drpYear.Text = "--Select--" Then
lblErrYear.Visible = True
Else
lblErrYear.Visible = False
End If
If drpMonth.Text = "--Select--" Then
lblErrMonth.Visible = True
Else
lblErrMonth.Visible = False
End If
If lstAcct.Items.Count = 0 Then
lblErrAcct.Visible = True
Else
lblErrAcct.Visible = False
End If
lblError.Visible = True
lblError.Text = "No value specified for the following parameter(s) *."
Else
lblErrYear.Visible = False
lblErrMonth.Visible = False
lblErrR1.Visible = False
lblErrR2.Visible = False
Call bindData()
Call bindGrid()
End If
End If
Else
If cboFilter.Text = "--Select--" Then
lblErrFilter.Visible = True
End If
lblError.Visible = True
lblError.Text = "No value specified for the following parameter(s) *."
End If
'Response.Redirect("~/Sites/CD/TopCon.aspx", True)
End Sub
as you can see the execution is done after I click on the filter button.
Here is my page load:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If User.Identity.IsAuthenticated = False Then
Response.Redirect("/Default.aspx", True)
Else
If User.IsInRole("chicken") = True Or User.IsInRole("dog") = True Or User.IsInRole("cat") = True Then
If Not IsPostBack Then
maxTop = 10
txtTop.Text = maxTop
Call bindData()
Call bindGrid()
lblUser.Text = lblUser.Text & User.Identity.Name
lblIP.Text = lblIP.Text & GetIPAddress()
cboFilter.TabIndex = 0
Call fillYear()
Call fillDMZCombo()
Call fillZoneCombo()
Call fillType()
Else
*Call bindGrid()*
End If
Else
Response.Redirect("/Default.aspx", True)
End If
End If
End Sub
Well I know the reason why the gridview refreshes when I click on my control that is set to autopostback it's because of the bindGrid that I inserted on my page_load inside the else.
It really seems to be a passive line of code. What really bothers me is why is it that my bindGrid inside the filter button does not execute when I query 100 records or more.
Here is my code for bindGrid:
Public Sub bindGrid()
IpAdd = GetIPAddress()
xUser = User.Identity.Name
ShowCon = New SqlConnection("some data connection")
ShowCon.Open()
cmdShowCon = ShowCon.CreateCommand
cmdShowCon.CommandTimeout = 600
cmdShowCon.CommandText = "some simple select statement"
daShowCon.SelectCommand = cmdShowCon
dsShowCon.Clear()
daShowCon.Fill(dsShowCon, "someTable")
grdTopCon.DataSource = dsShowCon
grdTopCon.DataBind()
End Sub
Any help would be much appreciated.
Try setting a breakpoint in the btnFilter_Click to see what's causing the problem. It maybe either caused by the algorithm inside it or inside the Page_Load event.

Can I use the ID of a control as parameter to subroutine in ASP using VB?

I have a page that has many (100+) fields that are all similar in their function. When the page is displayed, a value read from a database for each field will be checked to determine the display properties of the field and a couple of related fields. see code example.
If fieldvalue = 2 Then
Myfield.visible = False
Myfieldx.Checked = False
Myfieldz.visible = True
ElseIf fieldvalue = 1 Then
Myfield.visible = True
Myfieldx.Checked = True
Myfieldz.visible = False
Else
Myfield.visible = True
Myfieldx.Checked = False
Myfieldz.visible = False
End If
Each field has identical testing done. Each group of fields also has a fixed naming convention so that I can potentially use a subroutine to do this.
Fieldname, fieldname+x, fieldname+z
The code above works great but it is a lot of code to replicate for that many fields (each with a different ID). I would like to simplify the above code use a routine to do this testing. Something like
Protected Sub CheckStatusLoad(ByVal fieldID As String, ByVal fieldvalue As Integer)
Dim fieldIDx As String, fieldIDz As String
fieldIDx = String.Concat(fieldID, "x")
fieldIDz = String.Concat(fieldID, "z")
Dim Mainfield As New WebControls.Button
Dim MainfieldChkBox As New WebControls.CheckBox
Dim MainfieldStrike As New WebControls.Button
Mainfield = DirectCast(Page.FindControl(fieldID), WebControls.Button)
MainfieldChkBox = DirectCast(Page.FindControl(fieldIDx), WebControls.CheckBox)
MainfieldStrike = DirectCast(Page.FindControl(fieldIDz), WebControls.Button)
If fieldvalue = 2 Then
Mainfield.Visible = False
MainfieldChkBox.Checked = False
MainfieldStrike.Visible = True
ElseIf fieldvalue = 1 Then
Mainfield.Visible = True
MainfieldChkBox.Checked = True
MainfieldStrike.Visible = False
Else
Mainfield.Visible = True
MainfieldChkBox.Checked = False
MainfieldStrike.Visible = False
End If
End Sub
Then call this for each field being loaded
CheckStatusLoad("fieldname", testval)
This code now works using FindControl. I just needed to play around with the syntax to get the quotes adjusted properly.
The code above has been edited so that it now works. It took me a while to understand Page.FindControl, but once I got the proper syntax it worked just fine.

Is there a better solution then ViewData

I have a view that runs on a model RETLogModel which pulls from an entirely different connection string then a table called RecordsTaskViews. I need to pass information from RecordsTaskViews based on information gathered by my model. Currently my function looks like this:
Function RETLog(model As RETModels.RETLogModel) As ActionResult
Dim id As Integer = model.ActivityIDReturn
Dim id2 As Integer
Dim PS As RecordsTaskView = GlobalVar.db.PS.RecordsTaskViews.Find(id)
If model.ActivityIDReturn > 0 Then
id2 = model.ActivityIDReturn
Else : id2 = PS.RefActionID
End If
If model.ActivityIDError > 0 Then
ViewData("ActivityIDErrorValue") = model.ActivityIDError
Else : ViewData("ActivityIDErrorValue") = PS.RefActionID
End If
Dim PS2 As RecordsTaskView = GlobalVar.db.PS.RecordsTaskViews.Find(id2)
If model.ActivityIDReturn > 0 Then
If PS IsNot Nothing Then
ViewData("QRefActionID") = PS.RefActionID
ViewData("QQutDesc") = PS.QutDesc
ViewData("QTaskDesc") = PS.TaskDesc
ViewData("QClientCode") = PS.CltCode
ViewData("QClientName") = PS.CltDesc
ViewData("QMemberID") = PS.BenIDin
ViewData("QMemberName") = PS.BenNameLast & ", " & PS BenNameFirst
ViewData("QDateStart") = CDate(PS.DateStart).ToString("MM/dd/yyyy")
ViewData("QDateRes") = CDate(PS.DateResolution).ToString("MM/dd/yyyy")
ViewData("QCreateUser") = PS.UserIDCreation
ViewData("QLastChangeUser") = PS.UserIDLastChanged
ViewData("QDateReport") = CDate(PS.DateReport).ToString("MM/dd/yyyy")
Else
ViewData("QQutDesc") = ""
ViewData("QTaskDesc") = ""
ViewData("QClientCode") = ""
ViewData("QClientName") = ""
ViewData("QMemberID") = ""
ViewData("QMemberName") = ""
ViewData("QDateStart") = ""
ViewData("QDateRes") = ""
ViewData("QCreateUser") = ""
ViewData("QLastChangeUser") = ""
ViewData("QDateReport") = ""
End If
If PS2 IsNot Nothing Then
ViewData("ORefActionID") = PS2.RefActionID
ViewData("OQutDesc") = PS2.QutDesc
ViewData("OTaskDesc") = PS2.TaskDesc
ViewData("OClientCode") = PS2.CltCode
ViewData("OClientName") = PS2.CltDesc
ViewData("OMemberID") = PS2.BenIDin
ViewData("OMemberName") = PS2.BenNameLast & ", " & PS.BenNameFirst
ViewData("ODateStart") = CDate(PS2.DateStart).ToString("MM/dd/yyyy")
ViewData("ODateRes") = CDate(PS2.DateResolution).ToString("MM/dd/yyyy")
ViewData("OCreateUser") = PS2.UserIDCreation
ViewData("OLastChangeUser") = PS2.UserIDLastChanged
ViewData("ODateReport") = CDate(PS2.DateReport).ToString("MM/dd/yyyy")
Else
ViewData("ORefActionID") = ""
ViewData("OQutDesc") = ""
ViewData("OTaskDesc") = ""
ViewData("OClientCode") = ""
ViewData("OClientName") = ""
ViewData("OMemberID") = ""
ViewData("OMemberName") = ""
ViewData("ODateStart") = ""
ViewData("ODateRes") = ""
ViewData("OCreateUser") = ""
ViewData("OLastChangeUser") = ""
ViewData("ODateReport") = ""
End If
End If
If ModelState.IsValid Then
End If
Return View(model)
End Function
My issue is this is obviously a boat load of ViewData elements. Being as I already have #ModelType RETModels.RETLogModel specified in the view itself is there a more efficient way to pass the data to the view?
Is there a more efficient way to pass the data to the view?
Yes, use a ViewModel that contains all the relevant (combined) fields and bind that to the View.
And use an automated object mapper, such as AutoMapper, to copy data from your business models to the ViewModel.

InStr() asp classic form field validation

I'm trying to check for valid email address in a form field using:
if Request ("email") = "" then
bError = true
ElseIf Instr(1, email," ") <> 0 Then
bError = true
ElseIf InStr(1, email, "#", 1) < 2 Then
bError = true
else
*/go to success page*/
But if there is a space in the email address it still passes the validation. So my question is, how do I check for spaces using this method?
You're better off using a regular expression for this.
http://classicasp.aspfaq.com/email/how-do-i-validate-an-e-mail-address.html
Function isEmailValid(email)
Set regEx = New RegExp
regEx.Pattern = "^\w+([-+.]\w+)*#\w+([-.]\w+)*\.\w{2,}$"
isEmailValid = regEx.Test(trim(email))
End Function
Forget about all the elseif stuff do it simple...
Dim strEmail
Dim intErrors
intErrors = 0
strEmail = REQUEST("email")
strEmail = Trim(strEmail)
if strEmail = "" then intErrors = intErrors +1;
if instr(strEmail," ") > 0 then intErrors = intErrors +1;
if instr(strEmail,".") = 0 then intErrors = intErrors +1;
if instr(strEmail,"#") < 2 then intErrors = intErrors +1;
' Put as many test conditions as you want here
if intErrors = 0 then GotoSuccessPage
if Request ("email") = "" or Instr(email," ") > 0 or InStr(email, "#") < 2 then
bError = true
else
'go to success page
'BUT ABOUT OTHER ISSUES?
end if
---------------HERE IS A NON-REGEXP BASED EMAIL CHECKER, NOT SURE IF ITS FOOL PROOF BUT BETTER THAN THE SUBMITTED SNIPPET THAT SHOULD GET YOU GOING...
Function IsEmail(sCheckEmail)
Dim SEmail, NAtLoc
IsEmail = True
SEmail = Trim(sCheckEmail)
NAtLoc = InStr(SEmail, "#")
If Not (nAtLoc > 1 And (InStrRev(sEmail, ".") > NAtLoc + 1)) Then
IsEmail = False
ElseIf InStr(nAtLoc + 1, SEmail, "#") > NAtLoc Then
IsEmail = False
ElseIf Mid(sEmail, NAtLoc + 1, 1) = "." Then
IsEmail = False
ElseIf InStr(1, Right(sEmail, 2), ".") > 0 Then
IsEmail = False
End If
End Function

Conversion from string “” to type 'Byte' is not valid [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I have been struggling with this error for a couple days now, I have gone over the code to try to find an instance where I have the wrong type, but no luck. I am getting the "Conversion from string “” to type 'Byte' is not valid" when the submit button is clicked. So my thought is that there is something wrong in the Data_Save function. But I am unable to see my mistake. any help would be appreciated.
Protected Function Data_Save() As Boolean
Data_Save = False
Try
Dim newTable As New DemoOp_WebDataTable
Dim newRow As DemoOp_WebRow = newTable.NewRow()
newRow.DOW_FName = Me.txtFName.Text
newRow.DOW_LName = Me.txtLName.Text
newRow.DOW_Addr_1 = Me.txtAddr_1.Text
newRow.DOW_Addr_2 = Me.txtAddr_2.Text
newRow.DOW_City = Me.txtCity.Text
newRow.DOW_State = Me.ddState.SelectedValue.ToString
newRow.DOW_Zip = Me.txtZip.Text
newRow.DOW_Home_Phone = Me.txtHome_Phone.Text
newRow.DOW_Work_Phone = String.Empty
newRow.DOW_Cell_Phone = Me.txtCell_Phone.Text
newRow.DOW_Email = Me.txtEmail.Text
newRow.DOW_Dem_Exp = String.Empty
newRow.DOW_Wkd_Ret = String.Empty
newRow.DOW_Bilingual = String.Empty
newRow.DOW_Lang_Spk = String.Empty
newRow.DOW_Hrd_Store = Me.ddlOptQst12.SelectedItem.Value
newRow.DOW_StoreCode = Me.ddAd_Code.SelectedValue.ToString
newRow.DOW_In_Date = Now
newRow.DOW_18Plus = Me.rblnewqst1.SelectedValue
newRow.DOW_Transportation = Me.rblnewqst2.SelectedValue
newRow.DOW_AbleToStand = Me.rblnewqst3.SelectedValue
newRow.DOW_Internet = Me.rblnewqst4.SelectedValue
newRow.DOW_DirectDeposit = Me.rblnewqst5.SelectedValue
newRow.DOW_Experience = Me.rblnewqst6.SelectedValue
newRow.DOW_Outgoing = Me.rblnewqst7.SelectedValue
newRow.DOW_CulinarySkills = Me.rblnewqst8.SelectedValue
newRow.DOW_DemoWorkType = Me.ddlOptQst1.SelectedItem.Value
newRow.DOW_ReceiveTextMsgs = Me.rblOptQst2.SelectedValue
newRow.DOW_AgeCategory = Me.ddlOptQst3.SelectedItem.Value
newRow.DOW_ComputerSkill = Me.ddlOptQst4.SelectedItem.Value
newRow.DOW_CookingSkill = Me.ddlOptQst5.SelectedItem.Value
newRow.DOW_PhysicallyFit = Me.ddlOptQst6.SelectedItem.Value
newRow.DOW_AreasOfExp = GetCheckValues(chkOptQst7)
newRow.DOW_SpecialExpertise = GetCheckValues(chkOptQst8)
newRow.DOW_OtherLanguage = Me.ddlOptQst9.SelectedItem.Value
newRow.DOW_Felony = Me.rblnewqst11.SelectedValue
newRow.DOW_SOffender = Me.rblnewqst12.SelectedValue
newRow.DOW_ShopLift = Me.rblnewqst13.SelectedValue
newRow.DOW_FoodHandlers = Me.rblnewqst10.SelectedValue
newRow.DOW_OtherAgencies = GetCheckValues(chkOptQst10)
newRow.DOW_CookingAppliances = GetCheckValues(chkOptQst11)
newRow.DOW_Hrd_Store_Detail = Me.ddlOptQst13.SelectedItem.Value
Dim ta As DemoOp_WebTableAdapter = New DemoOp_WebTableAdapter
'ta.Insert(newRow.DOW_FName, newRow.DOW_LName, newRow.DOW_Addr_1, newRow.DOW_Addr_2, newRow.DOW_City, _
' newRow.DOW_State, newRow.DOW_Zip, newRow.DOW_Home_Phone, newRow.DOW_Work_Phone, newRow.DOW_Cell_Phone, _
' newRow.DOW_Email, newRow.DOW_Dem_Exp, newRow.DOW_Wkd_Ret, newRow.DOW_Bilingual, newRow.DOW_Lang_Spk, _
' newRow.DOW_Hrd_Store, newRow.DOW_Hrd_Store_Detail, newRow.DOW_StoreCode, newRow.DOW_18Plus, newRow.DOW_Transportation, _
' newRow.DOW_AbleToStand, newRow.DOW_Internet, newRow.DOW_DirectDeposit, newRow.DOW_Felony, newRow.DOW_SOffender, newRow.DOW_ShopLift, newRow.DOW_Experience, _
' newRow.DOW_Outgoing, newRow.DOW_CulinarySkills, newRow.DOW_FoodHandlers, newRow.DOW_DemoWorkType, newRow.DOW_ReceiveTextMsgs, _
' newRow.DOW_AgeCategory, newRow.DOW_ComputerSkill, newRow.DOW_CookingSkill, newRow.DOW_PhysicallyFit, _
' newRow.DOW_AreasOfExp, newRow.DOW_SpecialExpertise, newRow.DOW_OtherAgencies, newRow.DOW_CookingAppliances, newRow.DOW_OtherLanguage)
ta.Insert(newRow.DOW_FName, newRow.DOW_LName, newRow.DOW_Addr_1, newRow.DOW_Addr_2, newRow.DOW_City, _
newRow.DOW_State, newRow.DOW_Zip, newRow.DOW_Home_Phone, newRow.DOW_Work_Phone, newRow.DOW_Cell_Phone, _
newRow.DOW_Email, newRow.DOW_Dem_Exp, newRow.DOW_Wkd_Ret, newRow.DOW_Bilingual, newRow.DOW_Lang_Spk, _
newRow.DOW_Hrd_Store, newRow.DOW_StoreCode, newRow.DOW_18Plus, newRow.DOW_Transportation, _
newRow.DOW_AbleToStand, newRow.DOW_Internet, newRow.DOW_DirectDeposit, newRow.DOW_Experience, _
newRow.DOW_Outgoing, newRow.DOW_CulinarySkills, newRow.DOW_DemoWorkType, newRow.DOW_ReceiveTextMsgs, _
newRow.DOW_AgeCategory, newRow.DOW_ComputerSkill, newRow.DOW_CookingSkill, newRow.DOW_PhysicallyFit, _
newRow.DOW_AreasOfExp, newRow.DOW_SpecialExpertise, newRow.DOW_OtherLanguage, newRow.DOW_Felony, newRow.DOW_SOffender, newRow.DOW_ShopLift, newRow.DOW_FoodHandlers, newRow.DOW_OtherAgencies, newRow.DOW_CookingAppliances, newRow.DOW_Hrd_Store_Detail)
Data_Save = True
Catch ex As ApplicationException
Me.lblErrMessage.Text = ex.InnerException.ToString
End Try
End Function
Protected Function GetCheckValues(ByVal chklst As CheckBoxList) As String
GetCheckValues = String.Empty
Dim i As Integer
Dim sb As StringBuilder = New StringBuilder()
For i = 0 To chklst.Items.Count - 1
If chklst.Items(i).Selected Then
sb.Append(chklst.Items(i).Value & ",")
End If
Next
'remove the last comma in sb
If sb.Length > 0 Then
Dim InputValue As String
InputValue = Left(sb.ToString(), Len(sb.ToString()) - 1)
GetCheckValues = InputValue
End If
End Function
Protected Sub Reset_Controls()
btnSubmit.Visible = False
btnCancel.Visible = False
btnBack.Visible = True
txtFName.Enabled = False
txtLName.Enabled = False
txtAddr_1.Enabled = False
txtAddr_2.Enabled = False
txtCity.Enabled = False
ddState.Enabled = False
txtZip.Enabled = False
txtHome_Phone.Enabled = False
txtCell_Phone.Enabled = False
txtEmail.Enabled = False
ddlOptQst12.Enabled = False
ddlOptQst13.Enabled = False
ddStoreCode.Enabled = False
rblnewqst1.Enabled = False
rblnewqst2.Enabled = False
rblnewqst3.Enabled = False
rblnewqst4.Enabled = False
rblnewqst5.Enabled = False
rblnewqst6.Enabled = False
rblnewqst7.Enabled = False
rblnewqst8.Enabled = False
rblnewqst10.Enabled = False
rblnewqst11.Enabled = False
rblnewqst12.Enabled = False
rblnewqst13.Enabled = False
ddlOptQst1.Enabled = False
rblOptQst2.Enabled = False
ddlOptQst3.Enabled = False
ddlOptQst4.Enabled = False
ddlOptQst5.Enabled = False
ddlOptQst6.Enabled = False
chkOptQst7.Enabled = False
chkOptQst8.Enabled = False
ddlOptQst9.Enabled = False
chkOptQst10.Enabled = False
chkOptQst11.Enabled = False
End Sub
Protected Sub btnOKMsg_Click(ByVal sender As Object, ByVal e As System.EventArgs)
If Data_Save() Then
lblErrMessage.Text = "Your information has been submitted!"
Else
lblErrMessage.Text = "Error occurred while saving your entry. Click on 'Back' to return to main page."
End If
'Reset_Controls()
ModalPopupExtender1.Hide()
End Sub
Protected Sub btnCancelMsg_Click(ByVal sender As Object, ByVal e As System.EventArgs)
lblErrMessage.Text = "Your information was previously submitted."
ModalPopupExtender1.Hide()
End Sub
End Class
Here's a couple of suggestions to get you started:
Enable "Option strict" in your project options and fix any errors you may get. This will help you identify where you're trying to set a byte value with an empty string.
Remove all the try-catch-statements with an empty catch section.
Clean up the code, and remove the sections not relevant to your question.
Tell us where the exception occurs and the exception details...

Resources