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

[Solved] Grid-Ajax Binding

1 Answer 103 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.
Sonam
Top achievements
Rank 1
Sonam asked on 06 May 2012, 11:05 AM
Hi, I am new to Telerik MVC controls and i am using telerik Grid in my Project.  I am binding the Grid with Ajax but i am getting error message "Error! The requested URL returned 500-Internal Server Error"... no clue what is meant by this error...

Your help is highly appreciated here.

I am pasting my code here for your review:-
[GridAction]
       public ActionResult _Search(string _teamId)
       {
            
           InitiateEntities();
           var data = GetTeam(_teamId);
          
           return View(new GridModel(data));
       }
 
       public List<IAMPlanTeam> GetTeam(string _teamId)
       {
           InitiateEntities();
 
           var query = from p in _amplanEntity.AMPlanTeams
                       select p;
           if (!string.IsNullOrEmpty(_teamId)) query = query.Where(p => p.ukTeamCode== _teamId);
 
           return query.ToList();
 
       }

<% using (Ajax.BeginForm("Search", "AMPlanTeam", new AjaxOptions { HttpMethod = "Post",InsertionMode=InsertionMode.Replace }))
  {%>
  <%:Html.Label("Team ID:")%>  <%:Html.TextBox("teamcode", "")%>
   <input id="SearchButton" type="submit" value="Search"/>         
   <%} %>
$(document).ready(function () {
        $("#SearchButton").click(function () {
            var grid = $("#Result").data("tGrid");
            var teamid = $('#teamcode').val();
            grid.rebind({ _teamId: teamid });
        });
    });

<%Html.Telerik().Grid(Model)
                                               .Name("Result")
                                               .DataBinding(databinding => databinding.Ajax().Select("_Search", "AMPlanTeam", new {      _teamId = "TAD0312120001" }))
                                                 .Columns(columns =>
                                                   {
                                                       columns.Bound(o => o.pkTeamId).Title("Primary Key");
                                                       columns.Bound(o => o.ukTeamCode).Title("Team ID");
                                                   })
                                               .Pageable()
                                               .Render();
                                                                                        
                                               %>

1 Answer, 1 is accepted

Sort by
0
Pechka
Top achievements
Rank 1
answered on 07 May 2012, 06:22 AM
Tags
Grid
Asked by
Sonam
Top achievements
Rank 1
Answers by
Pechka
Top achievements
Rank 1
Share this question
or