Well, based on dropdown value I need the values in my form to be inserted into the Database table.. But it is not working now..
This is my aspx page-
<asp:DropDownList ID="DropDownList1" class="box" runat="server" AutoPostBack="True">
<asp:ListItem>Confirm Order</asp:ListItem>
<asp:ListItem>Tentative Order</asp:ListItem>
</asp:DropDownList>
And then I used switch..
switch (DropDownList1.SelectedValue)
{
case "Confirm Order":
... INSERT
break;
case "Tentative Order":
...Insert
break;
}
But its giving an error-
No mapping exists from object type System.Web.UI.WebControls.ListItem to a known managed provider native type.
What is the right way of doing it?
Make sure you are using:
DropDownList1.SelectedValue
or
DropDownList1.SelectedItem.Value
or
DropDownList1.SelectedItem.Text
in your INSERT Queries.
(And not DropDownList1.SelectedItem – this will give ListItem)