This is a migrated thread and some comments may be shown as answers.

[Solved] CheckBox in Grid

3 Answers 266 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ratndeep
Top achievements
Rank 1
Ratndeep asked on 21 Dec 2009, 02:23 PM
Hi All,
I am using following code to have a checkbox in Grid but somehow getting error.Is it correct code to have checkbox in grid.
Plz reply.

Error getting runtime:

Cannot use templates in Ajax or WebService binding mode


Code Of Grid:

 <%
              
                Html.Telerik().Grid<User>(Model.Data)
                    .Name("relationsGris")
                    .Columns(columns =>
                    {
                        columns.Add(x => x.Username).Title("User Name");
                        columns.Add(x => x.Name).Title("Name");
                         columns.Add(x=> {%>
               
                                              <%=Html.CheckBox("ttt",x.IsCustomer)%>
              
                                         <%});

                        columns.Add(x => x.Id).Format
                        (
                            string.Format("<form action=\"{0}\" method=\"post\">", Url.Action("Delete", new { userIdentificationId = "{0}" })) +
                            Html.CarsAndCargo().LinkButton().Class("icon delete").SubmitFormOnClick(false).ToString() +
                            "</form>"
                        )
                        .Encoded(false).Title("&nbsp;").Filterable(false).Sortable(false);
                        
                    })
                    .Sortable()
                    .Ajax(ajax => ajax.Action("AjaxGridBinding", "UserIdentification"))
                    .Render();
            %>

Thanks.

3 Answers, 1 is accepted

Sort by
0
Ratndeep
Top achievements
Rank 1
answered on 21 Dec 2009, 02:33 PM
Somehow i managed to solve this problem but i am not getting any clue how i can iterate throgh each record of grid at server side?
Anyone having any idea about this..Plz share.
0
Atanas Korchev
Telerik team
answered on 21 Dec 2009, 02:48 PM
Hello Ratndeep,

As the exception suggests you cannot use templates in ajax binding mode. Templates render HTML while Ajax binding outputs JSON. As a workaround you could use the Format. I have attached a sample project illustrating this approach.

All the best,
Atanas Korchev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Ratndeep
Top achievements
Rank 1
answered on 22 Dec 2009, 03:38 AM
Thanks Atanas.
Sample project  helped me to solve the problem.
Tags
General Discussions
Asked by
Ratndeep
Top achievements
Rank 1
Answers by
Ratndeep
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or