I’m just learning to program…I have a dropdownlist like this.
<div>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem >Alabama</asp:ListItem>
<asp:ListItem >Alaska</asp:ListItem>
</asp:DropDownList></div>
Using C# I want to send the selected item to database. Database field is County nvarchar(50) NULL,
I saw some example in C# backend .I found this one on the internet.Can i send above selected item from below coding ?
protected void Page_Load(object sender, EventArgs e)
{
ListItem[] items = new ListItem[3];
items[0] = new ListItem("One", "1");
items[1] = new ListItem("Two", "2");
items[2] = new ListItem("Three", "3");
DropDownList1.Items.AddRange(items);
if you want to get selected items from DropDownList1
if you need to insert this value to database then