I am utilizing client databinding and I cannot get the grid to populate with
anything. I am returning all my data is JSON format and its verified by
Web Developer Helper. The grid keeps displaying "No records to display.".
Code is posted below. Any ideas.
| <html xmlns="http://www.w3.org/1999/xhtml" > |
| <head runat="server"> |
| <title></title> |
| </head> |
| <script type="text/javascript"> |
| function RebindGrid() { |
| var mtv = $find("<%= RadGrid2.ClientID %>").get_masterTableView(); |
| mtv.rebind(); |
| return false; |
| } |
| function GridCommand(sender, args) { |
| } |
| </script> |
| <body> |
| <form id="form1" runat="server"> |
| <asp:ScriptManager id="PlaybookScriptManager" runat="server" /> |
| <asp:Button ID="dsd" runat="server" OnClientClick="return RebindGrid();" text="Rebind" /> |
| <br /> |
| <rad:RadGrid runat="server" ID="RadGrid2" AutoGenerateColumns="false" Height="670px" AllowFilteringByColumn="true"> |
| <MasterTableView DataKeyNames="EventID" ClientDataKeyNames="EventID" Height="670px" > |
| <Columns> |
| <rad:GridBoundColumn HeaderText="EventID" DataField="EventID" /> |
| <rad:GridBoundColumn HeaderText="EventName" DataField="EventName" /> |
| </Columns> |
| </MasterTableView> |
| <ClientSettings> |
| <ClientEvents OnCommand="GridCommand" /> |
| <Scrolling AllowScroll="true" /> |
| <DataBinding Location="Default.aspx" SelectMethod="GetEvents" DataPropertyName="Events" |
| FilterParameterName="filterexp" FilterParameterType="Linq" /> |
| <Selecting AllowRowSelect="true" /> |
| </ClientSettings> |
| </rad:RadGrid> |
| </form> |
| </body> |
| </html> |
| [WebMethod] |
| public static Dictionary<string, object> GetEvents(string filterexp) |
| { |
| var filter = !string.IsNullOrEmpty(filterexp); |
| var data = new DataClasses1DataContext(); |
| var events = (from e in data.Events |
| select new |
| { |
| EventID = e.EventID, |
| EventName = e.EventName |
| }) |
| .Where(filter ? filterexp : "EventID > 0"); |
| return new Dictionary<string,object> {{"Events", events}}; |
| } |