2014-03-19 67 views
0
Radio Button checked item should be true based on entry.isalbum value. Below is my View code..  

@foreach(abc.Models.ddt entry in entrydetails) 
     {  
    @if(entry.isAlbum=="Album") 
     { 
     <input type="radio" id="c" name="isAlbum" checked="checked" value="Album" /> 

     <label style="margin-right:10px" for="c"><span></span>Album</label> 
      } 

     <input type="radio" id="c1" name="isAlbum" value="Movies" /> 

     <label style="margin-right:10px" for="c1"><span></span>Movies</label> 

     <input type="radio" id="c2" name="isAlbum" value="Single" /> 

     <label style="margin-right:10px" for="c2"><span></span>Single</label> 

     </div> 
    } 
    } 

foreach循环包含与数据库,影片或单个数据库对应的值。 单选按钮应该是基于entry.isAlbum值为true。我们如何做到这一点,请帮助我们?上面的代码中提到了三个单选按钮。单选按钮检查将根据entry.Isalbum谷真实。请帮我在mvc中绑定单选按钮

回答

1

试试这个:

<input type="radio" id="c" name="isAlbum" @if(entry.isAlbum=="Album"){<text>checked="checked"</text>} value="Album" /> 

<input type="radio" id="c1" name="isAlbum" @if(entry.isAlbum=="Movies"){<text>checked="checked"</text>} value="Movies" /> 

<input type="radio" id="c2" name="isAlbum" @if(entry.isAlbum=="Single"){<text>checked="checked"</text>} value="Single" /> 
+0

非常感谢你对我的帮助....它已经完成 – dilipkumar1007