asp.net - How to bind IEnumerable List to JQGrid -


i need bind ienumerable list jqgrid using asp.net mvc 2. i'm having following.

model:

public class client     {         public int clientid { get; set; }         [required(errormessage="name required")]         [displayformat(convertemptystringtonull = false)]         public string name { get; set; }         public string address { get; set; }         public string mobile { get; set; }         public string telephone { get; set; }         public string fax { get; set; }         public string company { get; set; } } 

repository:

private stockdataclassesdatacontext dc; public ienumerable<client> getclients()         {              dc = new stockdataclassesdatacontext(constring.dbconnection);              ienumerable<client> cli = (from tbclient in dc.tblclients                                         select new client                                          {                                             address = tbclient.address,                                             clientid = tbclient.clientid,                                              company = tbclient.company,                                              fax= tbclient.fax,                                              mobile = tbclient.mobile,                                              name = tbclient.name,                                              telephone = tbclient.telephone                                          });             return cli;         } 

controller:

 public actionresult index()         {             jqgridclientrepository rep = new jqgridclientrepository();             ienumerable<client> clients = rep.getclients();             return view(clients);         } 

view:

<asp:content id="content2" contentplaceholderid="maincontent" runat="server">  <title>jqgrid asp.net mvc - demo</title>     <!-- jquery ui theme used grid -->         <link rel="stylesheet" type="text/css" media="screen" href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.10.0/themes/redmond/jquery-ui.css" />     <!-- css ui theme extension of jqgrid -->     <link rel="stylesheet" type="text/css" href="../../content/themes/ui.jqgrid.css" />         <!-- jquery library prerequisite jqgrid -->     <script src="http://ajax.microsoft.com/ajax/jquery/jquery-1.9.0.min.js" type="text/javascript"></script>     <!-- language pack - must included before jqgrid javascript -->     <script type="text/javascript" src="../../scripts/trirand/i18n/grid.locale-en.js"></script>     <!-- jqgrid javascript runtime -->     <script type="text/javascript" src="../../scripts/trirand/jquery.jqgrid.min.js"></script>         <h2>index</h2>      </asp:content> 

jqgrid needs json. there nice tutorial/extension on: http://blogs.teamb.com/craigstuntz/2009/04/15/38212/

after use extension configure jqgrid download data.


Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -