Load static select dropdown using ViewBag MVC & C#

ViewBag.list = new SelectList(new[]
            {
              new { Cat_Id = "0", Cat_Name = "--Select--" },
              new { Cat_Id = "1", Cat_Name = "Yarn" },
              new { Cat_Id = "2", Cat_Name = "Accessories" },
              new { Cat_Id = "3", Cat_Name = "Chemical" },
            }, "Cat_Name", "Cat_Name", 0);


@Html.DropDownList("Cat_Name", (SelectList)ViewBag.list,  new { @class = "form-control", @id = "Cat_Name" })

Comments

Popular posts from this blog

Easy Ui Jquery easyui-textbox change onChange event

Provision AWS EC2 Instance and RDS with Terraform, and Deploy Spring Boot App to EC2 Instance via GitHub Action Pipeline

npm install gets stuck at fetchMetadata