I am using a loop to create multi DropDownList in the same view. As a result of the loop, two lists are created. However the problem is when user select an item from one list, the other list will change its selection to be the same selection from the other one.
So, how do I avoid that, and make selection process separated from a list to another?
Here is the code generate the list
@Html.DropDownList("selectedDays", listItems, new { @class = "form-control", id="Day"+item.id })
EDIT:
The ListItem Code is this
List<SelectListItem> listItems = new List<SelectListItem>();
listItems.Add(new SelectListItem
{
Text = "1 day",
Value = "1"
});
listItems.Add(new SelectListItem
{
Text = "3 days",
Value = "3"
});
listItems.Add(new SelectListItem
{
Selected = true,
Text = "7 days",
Value = "7"
});
listItems.Add(new SelectListItem
{
Text = "15 days",
Value = "15"
});
listItems.Add(new SelectListItem
{
Text = "30 days",
Value = "30"
});
and This is the loop
@{
foreach (var item in companyList)
{
<div class="panel-body">
<form class="form-horizontal" role="form" action="/Admin/Telecom" method="post">
<div class="form-group">
<label class="col-sm-2 control-label">Payment View</label>
<div class="col-sm-6">
@Html.DropDownList("selectedDays", listItems, new { @class = "form-control", id="Day"+item.id })
</div>
<div class="col-sm-3">
<button type="submit" name="btnView" value="@item.TelecomCompanyName" class="btn btn-primary btn-rounded w-md waves-effect waves-light m-b-5">change</button>
</div>
</div>
</form>
</div>
}