SORU
23 NİSAN 2009, PERŞEMBE


Nasıl bu ASP.NET MVC çalışmak SelectList alabilir miyim?

Benim denetleyicisi içinde bir selectList, görünümünde görüntülemek için yarattım.

Sinek, biraz şey gibi .. bunu oluşturmak için çalışıyorum.

myViewData.PageOptionsDropDown = 
   new SelectList(new [] {"10", "15", "25", "50", "100", "1000"}, "15");

Derler, ama çıkış kötü

<select id="PageOptionsDropDown" name="PageOptionsDropDown">
    <option>10</option>
    <option>15</option>
    <option>25</option>
    <option>50</option>
    <option>100</option>
    <option>1000</option>
</select>

Hiçbir öğe seçili olduğunu nasıl fark ettin mi?

Bu durumu nasıl düzeltebilirim??

CEVAP
23 NİSAN 2009, PERŞEMBE


Ben böyle severim

IList<Customer> customers = repository.GetAll<Customer>();
IEnumerable<SelectListItem> selectList = 
    from c in customers
    select new SelectListItem
    {
    	Selected = (c.CustomerID == invoice.CustomerID),
    	Text = c.Name,
    	Value = c.CustomerID.ToString()
    };

İkinci bakışta sonra ne olduğunu bildiğimden emin değilim

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • calicoJake

    calicoJake

    29 EKİM 2007
  • ShotgunSandwichENT

    ShotgunSandw

    3 EKİM 2012
  • ThreadBanger

    ThreadBanger

    2 Mart 2007