0
Answer

fill the textboxes with selecting dropdownlist in mvc

jothi kumar

jothi kumar

10y
1.1k
1
hi to all,
              Here i'm doing dropdown list in mvc application. But now i want textbox/dropdown.Here i attached my code Kindly help me.Also when you start typing , the drop down should start filtering itself..For example type Ti will show only the state starting with Ti. Hope you understand what I mean.


DESCRIPTION:-
                     Customer is my module. in that module there r so many fields like name,country,state,city.for country state city i want textbox/dropdown. here i attached my code.
in model:-

public DbSet<State> State { get; set; }

in view:-

@Html.DropDownList("State_Name", (IEnumerable<SelectListItem>)ViewData["ViewState"], new { id = "State_Name", @class = "form-control control-text" })


in controller:-
List<SelectListItem> list = new List<SelectListItem>(); list.Add(new SelectListItem { Text = "Select Country", Value = "Select Country" });//set default text for DropdownList var cat = (from c in db.Country select c).ToArray();//get data from database using linq for (int i = 0; i < cat.Length; i++) { list.Add(new SelectListItem { Text = cat[i].Country_Name, Value = cat[i].Country_Cde.ToString() }); } ViewData["ViewCountry"] = list;above code i'm using viewdata.i want using model