i've created a web page taking inputs from user. There are some options for users which are optional. but when it is left empty; an error comes saying format of string is not correct. how can i do this? I've put "fieldvalidator" only for compulsory input. I'm inserting data in sql server 2000. here is my code
VB Code:
Sub SaveCustomer(ByVal s As Object, ByVal e As EventArgs) Handles btnSave.Click If Page.IsValid Then Dim objCustomer As New BusinessLogicLayer.MyCustomers objCustomer.RecordId = CType(txtRecordId.Text, Long) objCustomer.CustomerNo = CType(txtCustomerNo.Text, Long) objCustomer.RecordDate = CType(CurrentDate.Text, DateTime) objCustomer.Customername = txtCustomerName.Text objCustomer.CustomerCompanyName = txtCompanyName.Text objCustomer.CustomerBillingAddress = txtBillingAddress.Text objCustomer.CustomerTelePhoneNo = CType(txtTelePh.Text, Long) If Not objCustomer.Save() Then lblError.Text = "Could not save Customer" End If End If End Sub 'SaveUser
while i've declared variables in "MyCustomers" class as. here i've initialized those variables which are optional
VB Code:
Private _CustomerNo As Long = 0 Private _RecordId As Long Private _RecDate As DateTime Private _Customername As String Private _CustomerCompanyName As String = "" Private _CustomerBillingAddress As String Private _CustomerTelePhoneNo As Long




Reply With Quote