Wednesday, May 16, 2012

How to Bind a checkbox with Boolean value in the Telerik MVC3 grid

Spend hours to find the solution but when i checked the Telerik forum got it simply. Here is the code

Actully we use ClientTemplate and  checkbox inside it with databound to boolean.


 columns.Template(
               @<text>
        <input name="checkedRecords" type="checkbox" value="@item.AnyValue" title="checkedRecords" 
                        @if (item.MyCheckPost)
                        {
                            <text>checked="checked"</text>
                            <text>disabled="disabled"</text>
                        }
                    />
        </text>)
               .Title("").Width(36).HtmlAttributes(new { style = "text-align:center" });

Here item.MyCheckPost is True or False.

Simply modify it accordingly and use in your code.

Thanks

No comments:

Post a Comment