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

mvc webgrid not displaying on the page

2 Answers 81 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
test
Top achievements
Rank 1
test asked on 28 Jun 2011, 08:25 AM
I have data in my Model class:
public class Person
    {
        [Required]
        public int id { get; set; }
        [Required]
        public string name { get; set; }
        [Required]
        public int age { get; set; }

        public List<Person> GetPersons()
        {

            List<Person> p = new List<Person>() { new Person() { id=1, name="Andre", age=10},
                                        new Person() { id=2, name="Bennie", age=20},
                                        new Person() { id=3, name="Roel", age=30},
                                        new Person() { id=4, name="Jeroen", age=40},
                                        new Person() { id=5, name="Arjan", age=50},
                                        new Person() { id=6, name="PietJan", age=60},
                                        new Person() { id=7, name="Alex", age=70},
                                        new Person() { id=8, name="Wim", age=80},
                                        new Person() { id=9, name="Jan", age=90},
                                        //new List<B) { }
                                      };

           
            return p;
        }

There is a function in Controller which returns the data from GetPersons

In .cshtml file i m binding the grid to GetPersons to display data. But nothing displays on the screen. There is no grid on the screen. What am i doing wrong

 Html.Telerik().Grid(this.Model)
                   .Name("grdPersonView")
                   .Columns(columns =>
                       {
                           columns.Bound(p => p.id);
                           columns.Bound(p => p.age);
                           columns.Bound(p => p.name);
                       })
                                                 
                   .Pageable(pager => pager.PageSize(20))
                   .Sortable(sorting =>
                       {
                           sorting.SortMode(GridSortMode.MultipleColumn);
                           sorting.OrderBy(sortOrder => sortOrder.Add(p => p.id));
                       }
                           );

2 Answers, 1 is accepted

Sort by
0
Demon
Top achievements
Rank 1
answered on 28 Jun 2011, 08:31 AM
Hi,

Check your code block tags. You should have either

<%=  Html.Telerik().Grid()  %>

or

<%  Html.Telerik().Grid().Render()  %>
0
Accepted
Demon
Top achievements
Rank 1
answered on 28 Jun 2011, 08:39 AM
For Razor:

@( Html.Telerik().Grid() )

or

@{ Html.Telerik().Grid().Render(); }
Tags
Grid
Asked by
test
Top achievements
Rank 1
Answers by
Demon
Top achievements
Rank 1
Share this question
or