Hi All
I am new to .net
I have a problem where when I debug my code, there is no value when trying to execute sql query. The value in cbContact.text is blank. cbContact is a dropdownlist where I already choose the selected value. I already did try change the property to .selectedvalue but still same. Appreciate on you guys advise. Please find my coding as below.
Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click
If txtprojectname.Text = "" Then
cf.messagebox("Please key in Project Name !", Me)
txtprojectname.Focus()
Exit Sub
End If
Dim StrSQL As New StringBuilder
If txtprojectname.Text <> "" Then
StrSQL.Remove(0, StrSQL.Length)
StrSQL.Append("INSERT INTO tblorderdetails(Customer,SSIStaff,PONumber,CONumber,ProjectName,DateOrderReceived) VALUES (")
StrSQL.Append("'" + cbCustCode.Text + "'")
StrSQL.Append(",'" + cbContact.Text + "'")
StrSQL.Append(",'" + txtponum.Text + "'")
StrSQL.Append(",'" + txtconum.Text + "'")
StrSQL.Append(",'" + txtprojectname.Text + "'")
If Not IsNothing(dpOrderReceive.SelectedValue) Then
StrSQL.Append(",'" + Format(CDate(dpOrderReceive.SelectedValue), "yyyy-MM-dd") + "')")
Else
StrSQL.Append(",Null)")
End If
cf.runSQLComm(StrSQL.ToString)
cf.messagebox("Record created !", Me)
Exit Sub
Else
Exit Sub
End If
End Sub
As for the cbContact here is the coding. I query the value from a table.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Session.LCID = 2057
Me.MaintainScrollPositionOnPostBack = True
BindComboBoxList()
End Sub
Sub BindComboBoxList()
tblData = cf.GetDataTable("Select ContactPerson from tblcontactperson Order by ContactPerson")
cbContact.Items.Clear()
cbContact.Items.Add("")
For Each r As DataRow In tblData.Rows
cbContact.Items.Add(r(0).ToString.Trim)
Next
End Sub