Raspi Surya
Raspi Surya

Reputation: 315

Display as checkbox from database value (1 / 0)

I am building a website for user privilage setting. I use ASP MVC for programming. In my Database, I have column admin_privilage and user_privilage with value either 1/0.

Here is the screen and the code

<td>@item.admin_privilage</td>
<td>@item.user_privilage</td>

screen

What I want to do is to display it as a checkbox. If the value is true, then displayed as checked box. if false, then displayed as unchecked box.

enter image description here

anyone can help how to do this in asp mvc?

Upvotes: 0

Views: 370

Answers (1)

Shai Aharoni
Shai Aharoni

Reputation: 1957

You can use the @CheckBox HTML helper, like this:

<td>@Html.CheckBox("admin_privilage",item.admin_privilage)</td>
<td>@Html.CheckBox("user_privilage",item.user_privilage)</td>

Upvotes: 1

Related Questions