Connecting Tech Pros Worldwide Forums | Help | Site Map

Inserting values into sql dbase from a dropdownlist control

Chumley the Walrus
Guest
 
Posts: n/a
#1: Jul 21 '05
I'm trying to add a drop down list to my data insertion script, using
the sqlparamter object . The form coding on the web page:


<asp:dropdownlist id="frmstate" runat="server">
<asp:ListItem Value="nv" Selected="True">-</asp:ListItem>
<asp:ListItem Value="az">arizona</asp:ListItem>
<asp:ListItem Value="ca">cal</asp:ListItem>
<asp:ListItem Value="or">oregon</asp:ListItem>

</asp:dropdownlist>

....and the process example i'm using below to insert the data and
bind it:


cmd.Parameters.Add(New SQLParameter("@state", frmstate.item.key))
cmd.Parameters.Add(New SQLParameter("@city", frmcity.text))

....getting an error on the @state line, as "item" is not a member of
'System.Web.UI.WebControls.DropDownList' - just wondering what syntax
to use for frmstate.item.key , as using .text along with asp:textbox
controls is working fine for me.

thanks in advance
chumley

Closed Thread


Similar .NET Framework bytes