I had a question. In Visual Studio 2008 i have created an asp website. I'm creating a drop down list and want to submit the value of the drop down list back to an SQL DB. I created a simple form that has one button and one drop down list as a test go ensure I can write.
I've been having the hardest time posting back to the server. I keep getting an error after I hit the button that says
"InvalidCastException was unhandled by user code"
Unable to Cast object of type
'System.Web.UI.WebControls.SqlDataSourceCommandEventArgs' to type
'System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs'.
This is the code for my .aspx.vb
---------------------------------
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
formresults.Insert()
End Sub
Protected Sub SqlDataSource1_Inserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) Handles formresults.Inserting
e.Command.Parameters("@ContactType").Value = ContactType.Text
End Sub
End Class
----------------------
This is the code for my .aspx page
------------------------------
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "" target="_blank">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
" target="_blank">http://www.w3.org/1999/xhtml">
Untitled Page