Hi All,
I'm stuck!!
I've got a page with 3 dropdowns on it and a submit button to pass the data to a table in a database.
The code is as follows:
Sub Page_Load(sender as Object, e as eventargs)
dim objConn as new OleDbConnection ("Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=C:\blah\blah\blah.mdb)
objConn.Open()
Const strSQL as String = "SELECT UserID FROM tblUser"
Dim objCmd as New OleDbCommand (strSQL, objConn)
ddUserID.DataSource = ObjCmd.ExecuteReader()
ddUserID.DataBind()
objConn.Close()
objConn.Open()
Const strSQL2 as String = "SELECT ProjectID FROM tblProject"
Dim objCmd2 as New OleDbCommand (strSQL2, objConn)
ddProjectID.DataSource = ObjCmd2.ExecuteReader()
ddProjectID.DataBind()
objConn.Close()
End Sub
Sub Submit(Sender As Object, e as EventArgs)
if Page.IsValid then
dim objUserProject as New DecSup.UserProject
dim objUserProjectDetails as New DecSup.UserProjectDetails
objUserProjectDetails.UserID = ddUserID.Selecteditem.Text
objUserProjectDetails.ProjectID = ddProjectID.Selecteditem.Text
objUserProjectDetails.Type = ddType.Selecteditem.Text
objUserProject.AddUserProject(objUserProjectDetails)
Response.Redirect("success.aspx")
else
lblMessage.Text = "Please Check - Some information is invalid. User NOT allocated to a project."
end if
End Sub
the Drop downs ids are ddUserID, ddProjectID and ddType. ddType has the following code:
<tr><td><font face="arial">Type:</font></td><td><font face="arial">
<asp:Dropdownlist id="ddType" runat="server" DataTextField="Type" DataValueField="Type">
<asp:ListItem>Member</asp:ListItem>
<asp:ListItem>Controller</asp:ListItem>
</asp:Dropdownlist>
The third dropdown - ddType (with the hardcoded options) is submitted to the database fine, but the first two default to the value at the top of the list. I want to submit the data that the user chooses (obviously).
any ideas what I'm doing wrong? if you need to vb code let me know and I'll
submit it.
thanks
DJ