Insert searchable DropDownList selected value into database in ASP.Net MVC

on Nov 11, 2021 11:10 PM

As per your refer link below.

Searchable DropDownList in ASP.Net MVC

After Changed from

@Html.DropDownListFor(m => m.CodeItem, Model.ItemList)


@Html.DropDownList("ddlitem", Model.ItemList)

it value is not inserting into database.

@model WebApplication9.Models.Bigbalprd
    Layout = null;
    <link rel="stylesheet" href="" />
    <script type="text/javascript" src=""></script>
    <script type="text/javascript" src=""></script>
    <script type="text/javascript">
        $(function () {
    <meta name="viewport" content="width=device-width" />

    <h1>Insert Data Into Data using MVC EDO</h1>>
        @using (Html.BeginForm("Index", "Bigbale", FormMethod.Post))
        <table border="1" bgcolor="yellow" width="400px" height="250px">
                <td>@Html.DropDownListFor(m => m.CodeItem, Model.ItemList ,"ddlitem")
                    @*@Html.DropDownList("ddlitem", Model.ItemList)*@</td>

                <td>@Html.DropDownListFor(m => m.SecID, Model.SectionList)</td>

                <td>@Html.DropDownListFor(m => m.CID, Model.SectionList)</td>

                <td>@Html.TextBoxFor(m => m.Bpqty)</td>
                <td>@Html.TextBoxFor(m => m.Bweight)</td>

                <td><input class="submit" type="submit" /></td>


Download FREE API for Word, Excel and PDF in ASP.Net: Download
on Nov 12, 2021 07:02 PM
akhter says:
@Html.DropDownListFor(m => m.CodeItem, Model.ItemList ,"ddlitem")

Change with below.

@Html.DropDownListFor(m => m.CodeItem, Model.ItemList, new { @id="ddlitem" })