Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using MVC grid using bootsrap. I want to add checkbox inside gridview in first column. And want other controls also. How to add it? I have installed Grid.MVC in project.

//code
@using GridMvc.Html

C#
@Html.Grid(Model).Columns(columns => {
   columns.Add(c => c.title).Titled("Title").Sortable(true).Filterable(true);
   columns.Add(c => c.modified_dt).Titled("Date").Sortable(true).Format("{0:MM/dd/yyyy}");

   }).WithPaging(2).Sortable(true);
Posted
Updated 11-Aug-15 23:32pm
v3

1 solution

C#
@Html.Grid(Model).Columns(columns => {
 columns.Add().Titled("<input name="allChk" type="checkbox" /> " ) .Encoded(false).Sanitized(false).SetWidth(30).RenderValueAs(o =>Html.CheckBox("checked", false, new { name = "selectedIds", value = o.pk_id, OnClick = "selectedCheckbox(this," + o.pk_id + ");" }));
 columns.Add(c=>c.title).Titled("Title").Sortable(true).Filterable(true);
   columns.Add(c =>c.date).Titled("Date").Sortable(true);
   }).WithPaging(2).Sortable(true);
}
 
Share this answer
 
Comments
Member 9579525 17-Aug-15 2:44am    
I got the solution for above question but now I want to select all checkboxes when I check that header chechbox. how to do it?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900