I am new in MVC Razor and trying to convert a webform project to MVC. Now I am facing difficulties how to use dropdown which will be Razor C# syntax.
My Webfrom code -
aspx page - <asp:DropDownList runat="server" ID="ddl_1" AutoPostBack="true" > </asp:DropDownList>
code behind -
if (ddl_1.Items.Count == 0)
ddl_1.DataSource = GetData(); //this function is working find and I am ok with this
ddl_1.Items.Insert(0, new ListItem("All", "0"));
ddl_1.SelectedIndex = 0;
Please help me how it will be when I will use this in my MVC C# Razor project. I also want to show the selected value in a LABEL.
Thanks in advance