I am getting the following error on line 26. can someone tell me where I am going wrong. Its a radiobuttonlist I am trying to get the value from
Thanks
Code:
Line 26: cmdInsert.Parameters.AddWithValue("@Gender", rdoGender.SelectedItem.Value)
Code:
Imports System.Data.SqlClient
Imports System.Data
Imports System.Web.UI.WebControls.RadioButtonList
Partial Class register
Inherits System.Web.UI.Page
Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim conTIBMembers As SqlConnection
Dim strInsert As String
Dim cmdInsert As SqlCommand
Dim rdoGender As System.Web.UI.WebControls.RadioButtonList = Nothing
conTIBMembers = New SqlConnection("Server=(local);UID=sa;PWD=admin2010;database=TIB")
strInsert = "Insert dbo.Members (Firstname, Surname, Nationality, Gender, DateofBirth, EmailAddress, Password, MailingList) Values (@Firstname, @Surname, @Nationality, @Gender, @DateofBirth, @EmailAddress, @Password, @MailingList)"
cmdInsert = New SqlCommand(strInsert, conTIBMembers)
cmdInsert.Parameters.AddWithValue("@Firstname", txtFirstname.Text)
cmdInsert.Parameters.AddWithValue("@Surname", txtSurname.Text)
cmdInsert.Parameters.AddWithValue("@Nationality", cboNationality.SelectedItem.Text)
cmdInsert.Parameters.AddWithValue("@Gender", rdoGender.SelectedItem.Value)
cmdInsert.Parameters.AddWithValue("@DateofBirth", txtDateofBirth.Text)
cmdInsert.Parameters.AddWithValue("@EmailAddress", txtEmail.Text)
cmdInsert.Parameters.AddWithValue("@Password", txtPassword.Text)
cmdInsert.Parameters.AddWithValue("@MailingList", chkMailingList.Checked)
conTIBMembers.Open()
cmdInsert.ExecuteNonQuery()
conTIBMembers.Close()
End Sub
End Class