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

  • Flash CS6 Video Tutorials for Beginners (Actionscript 3 Gaming)

    Flash CS6 Vi

    14 EYLÜL 2012
  • hockeywebcasts

    hockeywebcas

    31 EKİM 2012
  • metallmanutza13

    metallmanutz

    13 NİSAN 2007