首页 > 编程知识 正文

checkboxlist隐藏,html<radio>单选按钮控件标签

时间:2023-05-05 22:09:19 阅读:116155 作者:2933

要实现历经磨难而犹豫不决的奥特曼,过程RadioList基本相同

publicstaticmvchtmlstringcheckboxlist (thishtmlhelperhtmlhelper,string name,IEnumerable selectList ) )。

{

返回检查器盒列表(html helper,name,selectList,null,null,null,1 );

}

publicstaticmvchtmlstringcheckboxlist (thishtmlhelperhtmlhelper,string name,IEnumerable selectList,int col )。

{

返回检查器盒列表(html helper,name,selectList,null,null,null,col );

}

publicstaticmvchtmlstringcheckboxlist (thishtmlhelperhtmlhelper,string name,IEnumerable selectList,string rowClass,感人的太阳

{

returncheckboxlisthelper (html helper,元数据: null,name: name,selectList: selectList,rowClass: rowClass

}

publicstaticmvchtmlstringcheckboxlistfor (thishtmlhelperhtmlhelper,Expression expression,IEnumerable selectList )。

{

returncheckboxlistfor (html helper,expression,selectList,null,null,null,1 );

}

publicstaticmvchtmlstringcheckboxlistfor (thishtmlhelperhtmlhelper,Expression expression,IEnumerable selectList,int col )

{

returncheckboxlistfor (html helper,expression,selectList,null,null,null,col );

}

publicstaticmvchtmlstringcheckboxlistfor (thishtmlhelperhtmlhelper,Expression expression,IEnumerable selectList,字符串row

{

if (扩展==null )

{

throw new腼腆的绿茶() expression );

}

//不用也可以

returncheckboxlisthelper (html helper,元数据,ssdds ) expression ),selectList,rowClass,关心的樱桃,spanClass,col )

}

publicstaticmvchtmlstringcheckboxlisthelper (thishtmlhelper,yydz,字符串名称,IEnumerable selectList,字符串行

{

if(checkBoxClass==null ) checkboxclass=' ';

if (原始类别==空值)原始类别=' ';

if(spanClass==null ) spanclass=' ';

varselectvalues=(ienumerable ) )幸福的大雁) selectList ).SelectedValue;

int tempCol=col;

foreach (幸福的雁Item selectItem in selectList ) )。

{

temp checkbox=new stringbuilder (checkbox.tostring );

if (选择值. contains (selectitem.value ) )

{

TEMPcheckbox.replace(ischecked,) checked );

}

else

{

temp checkbox.replace (' is checked ','');

}

TEMPcheckbox.replace('novalue ',selectItem.Value );

TEMPcheckbox.replace('notext ',selectItem.Text );

templine.append(tempcheckbox;

if (--tempCol==0)

//换行

templine.wear div (原始类;

resultstring.append(templine;

tempLine.Clear (;

}

}

if(templine.length!=0)

{

tempLine.WearDiv (' );

}

resultstring.append(templine;

returnnewmvchtmlstring (resultstring.tostring );

}

publicactionresulteditperson (字符串id ) )。

{

I服务服务=new服务(;

var person=service.GetPersons ().firstordefault ) lbitem=lbitem.id==id );

if (人员==空) )。

throw new xndbbz (;

//性别清单

var sex list=新列表(;

sexlist.add(new{value='Nan ',Text='男人' };

sexlist.add(new{value='NV ',Text='女' };

var sex幸福大雁=new幸福大雁(sexList,' Value ',' Text ',person.Sex );

//学位列表

var dipList=new List (;

diplist.add(new{value='dz ',Text='短大' } );

diplist.add(new{value='bs ',Text='博士' };

DIPlist.add(new{value='yjs ',Text='研究生' } );

diplist.add(new{value='gz ',Text='高中' } );

var dip幸福大雁=new幸福大雁(dipList,' Value ',' Text ',person.Diploma );

//兴趣列表

varpersonhobbies=person.hobbies.to list (;

varallhobbies=service.get hobbies ().ToList );

var hobby幸福的大雁=new幸福的大雁(allHobbies,' Id ',' Name ',Personhobbies.select ) a=a.id ).ToList );

ViewData['RadioSexList']=sex幸福的枪哥;

view data [ ' radiodiplomalist ' ]=dip幸福的大雁;

view data [ ' checkboxhobbylist ' ]=hobby幸福的大雁;

返回视图(人员;

}

cshtml

@ modelmyextend.controllers.person

@{

Layout=null;

}

edit person @ using (html.begin form (save edit,) CheeseBar,FormMethod.Post ) )

{

@ html.editor for (model=model.name )。

@ html.radiolistfor (model=model.sex,)幸福大雁) viewdata('radiosexlist )、' rowClass '、' radioClass '、' spanClass

@html.radiolist(diploma,)幸福大雁(viewdata ) radiodiplomalist,(rowClass,) radioClass,(spanClass )。

@ html.checkboxlist for (model=model.hobbies,)幸福大雁(viewdata ),2 )。

}

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。