多个复选框帮助 [英] Multiple Checkbox Help

查看:85
本文介绍了多个复选框帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在asp.net MVC 3中创建一个应用程序
我的视图上应该有多个复选框

我有一个模型类,并基于此模型生成视图,该问题是由多个复选框引起的

这是我的模型课

Hi,
I am creating an application in asp.net MVC 3
I should have multiple check boxes on my View

I have a model class and based on it i am generating my View the problem is arising with multiple Check box

here is my Model class

public class FormModel
   {
       public string ID { get; set; }
       public int No { get; set; }
       public string type { get; set; }
       public string value { get; set; }

       public string[] Ctype //Multiple Check Boxes
       {
           get;
           set;
       }

   }

and on View i am using this


<table>
    <tr>
    <td>Enter ID:</td>
    <td> @Html.TextBoxFor(m => m.ID)</td>
    </tr>
    <tr>
    <td>Enter Number of controls wanted:</td>
    <td>@Html.TextBoxFor(m => m.No)</td>
    </tr>
    <tr>
    <td>Select type of control:</td>
    <td> @Html.DropDownListFor(m => m.type,items)</td>    
    <td>@Html.CheckBoxFor(m=> m.Ctype)</td>
    </tr>
    <tr>
    <td>Value:</td>
    <td>@Html.TextBoxFor(m => m.value)</td>

m is the reference of model class
</tr></table>



问题出现在CheckBoxFor,它说不能将string []隐式转换为bool


谁能帮我解决这个



The problem is arising at CheckBoxFor, it is saying that cannot implicitly convert string[] to bool


Can any one help me out on this

推荐答案



只有在具有布尔值时才可以使用CheckBoxFor.否则,您可以使用Simply Checkbox来实现.

对于您的解决方案,您可以使用"CheckBox"而不是"CheckBoxFor"来生成多个复选框.

问候,
萨加尔·索兰基(Sagar Solanki)
Hi,

You can only take CheckBoxFor when you have bool value. Or else you can use Simply Checkbox for the same.

For your solution you can generate multiple checkboxes with use of "CheckBox" instead of "CheckBoxFor"

Regards,
Sagar Solanki


这篇关于多个复选框帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆