Bir ASP.NET MVC projesinde çalışıyorum ve formumda bir DropDown listesi özel uygulamasına sahibim. Bir hesap seçiyorum ve bu hesaba göre hesap altında yapılan kişileri seçebilmek istiyorum. İşte Özel DropDownFor yükleme Varlığa göre değer
buradapublic static MvcHtmlString AccountContactsDropdownFor<TModel, TEnum>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TEnum>> expression, Guid parentId, object htmlAttributes = null)
{
QueryRequestHelper<AccountContacts, FMRequestDispatcher> request = new QueryRequestHelper<AccountContacts, FMRequestDispatcher>();
EntityReference reference = new EntityReference() { EntityName = "Account", Id = parentId };
int count = 0;
IEnumerable query = request.Query(string.Empty, string.Empty, 0, 100, out count, reference);
List<SelectListItem> items = new List<SelectListItem>();
foreach (Contact contacts in query)
{
SelectListItem li = new SelectListItem();
li.Value = contacts.Id.ToString();
li.Text = contacts.FirstName[0] + ". " + contacts.LastName;
items.Add(li);
}
return SelectExtensions.DropDownListFor(htmlHelper, expression, items, htmlAttributes);
}
Ve aşağıda benim kod bunun kod
<li>
@Html.Label(Localization_Financial.Account) <br>
@Html.AccountNameDropdownFor(m => m.AccountId)
</li>
<li>
@Html.Label(Localization_Financial.Contact) <br>
@Html.AccountContactsDropdownFor(m => m.ContactId, Model.AccountId)
</li>
Yani dropdownfor bir hesap seçiyorum zaman benim şeklidir (İletişim model accountid vardır) Yukarıda uygulamamın yeniden yüklenmesini veya bir şeyler yapmasını istiyorum. Bu nedenle, hesabıma ait kişilerle birlikte seçili kutuyu günceller.
Bunu yapmanın etkili bir yolu var mı?