Dropdown List
-
I have a webform whereby i use a dropdown list to select fields like title,province etc. but the problem is that when i select a value from the dropdown and click save button,the field in the database becomes blank. my code is as follows: BUSINESS LAYER Public Function GetTitle() As Data.DataSet Dim strSQL As String Dim obj As Datalayer.Database = New Datalayer.Database 'strSQL = "Select * from UserProfile with (nolock) where UserName='" & strUserName & "' and Status = 'A'" strSQL = "Select TitleID, Title from Title1 with (nolock) " GetTitle = obj.GetDataSet(strSQL) obj.Close() Exit Function End Function PRESENTATION LAYER Private Sub LoadTitle() Dim ds As New Data.DataSet Dim objdata As Businesslayer.Contractors = New Businesslayer.Contractors ds = objdata.GetTitle cbotitle.DataSource = ds cbotitle.DataBind() cbotitle.Items.Add(New ListItem("Select...", "")) cbotitle.Items.Item(cbotitle.Items.Count - 1).Selected = True End Sub BUTTON SAVE Dim obj As Businesslayer.Contractors = New Businesslayer.Contractors Dim ds As Data.DataSet ds = obj.Getcontractor(txtfirstname.Text) obj.AddContractor(txtID.Text, cbotitle.SelectedItem.Value, cbogender.SelectedItem.Value, txtfirstname.Text, txtlastname.Text, _ txtIDNumber.Text, txttel.Text, txtcell.Text, txtfax.Text, txtemail.Text, _ cbodepartment.SelectedItem.Value, txtlocation.Text, txtcity.Text, txtpostal.Text, txtoccupation.Text, cbomtype.SelectedItem.Value, _ cboprovince.SelectedItem.Value, txtpassport.Text) UserMsgBox("Successfully add") Karabo Mekgwe
-
I have a webform whereby i use a dropdown list to select fields like title,province etc. but the problem is that when i select a value from the dropdown and click save button,the field in the database becomes blank. my code is as follows: BUSINESS LAYER Public Function GetTitle() As Data.DataSet Dim strSQL As String Dim obj As Datalayer.Database = New Datalayer.Database 'strSQL = "Select * from UserProfile with (nolock) where UserName='" & strUserName & "' and Status = 'A'" strSQL = "Select TitleID, Title from Title1 with (nolock) " GetTitle = obj.GetDataSet(strSQL) obj.Close() Exit Function End Function PRESENTATION LAYER Private Sub LoadTitle() Dim ds As New Data.DataSet Dim objdata As Businesslayer.Contractors = New Businesslayer.Contractors ds = objdata.GetTitle cbotitle.DataSource = ds cbotitle.DataBind() cbotitle.Items.Add(New ListItem("Select...", "")) cbotitle.Items.Item(cbotitle.Items.Count - 1).Selected = True End Sub BUTTON SAVE Dim obj As Businesslayer.Contractors = New Businesslayer.Contractors Dim ds As Data.DataSet ds = obj.Getcontractor(txtfirstname.Text) obj.AddContractor(txtID.Text, cbotitle.SelectedItem.Value, cbogender.SelectedItem.Value, txtfirstname.Text, txtlastname.Text, _ txtIDNumber.Text, txttel.Text, txtcell.Text, txtfax.Text, txtemail.Text, _ cbodepartment.SelectedItem.Value, txtlocation.Text, txtcity.Text, txtpostal.Text, txtoccupation.Text, cbomtype.SelectedItem.Value, _ cboprovince.SelectedItem.Value, txtpassport.Text) UserMsgBox("Successfully add") Karabo Mekgwe
the field in the database becomes blank.? you mean. the selected value doesn't store in database. some tips. 1. Set the breakpost in Button Save. Check the selected value of combobox. 2. Check whether you got any value (eg: paraProvince) in Businesslayer.Contractors.AddContractor() function. [Make ensure that all values of parameters has been passed from Presentation Layer to BusinessLayer.] 3. Check the SQL Statement.. [Make ensure that all values of parameters has been passed from BusinessLayer to DataLayer.]
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Thank you. :)