毕业论文开发语言企业开发JAVA技术.NET技术WEB开发Linux/Unix数据库技术Windows平台移动平台嵌入式论文范文英语论文
您现在的位置: 毕业论文 >> net技术 >> 正文

jquery easy ui datagrid获取不了数据

更新时间:2013-6-12:  来源:毕业论文

<body>     <div>         <table id="myTable"></table>     </div> </body>


JavaScript code?1234567891011121314151617181920212223242526272829     <script type="text/javascript">         $(function () {             $('#myTable').datagrid({                 title: 'datagrid',                 url: 'datagrid_data.ashx',                 idField: 'id',                 width: 400,                 columns: [[                     { field: 'name', title: '名字', width: 100 },                     { field: 'age', title: '年龄', width: 100 },                     { field: 'sex', title: '性别', width: 100 }                 ]],                 pagination: true,                 pageSize: 10,                 pageList: [10, 20, 30, 40, 50]             });               $.ajax({                 url: 'datagrid_data.ashx',                 data: 'aa:1',                 type: 'post',                 dataType: 'json',                 success: function (data) {                     console.info(data);                 }             });         })     </script>


datagrid_data.ashx:

C# code?public void ProcessRequest(HttpContext context)         {             GridView<userInfo> gv = new GridView<userInfo>();             gv.rows = getlist();             gv.total = getlist().Count;             JavaScriptSerializer json = new JavaScriptSerializer();             string result = json.Serialize(gv);             context.Response.Write(result);             context.Response.End();         }           private DataTable GetTable()         {             DataTable dt = new DataTable();             dt.Columns.Add("id", typeof(int));             dt.Columns.Add("name", typeof(string));             dt.Columns.Add("age", typeof(int));             dt.Columns.Add("sex", typeof(string));               DataRow dr = dt.NewRow();             string[] name = { "张三", "李四", "王五", "赵六" };             string[] sex = { "男", "女", "女", "男" };               for (int i = 0; i < 4; i++)             {                 dr["id"] = 0 + i;                 dr["name"] = name[i];                 dr["age"] = 14 + i;                 dr["sex"] = sex[i];             }             dt.Rows.Add(dr);             return dt;                       }           private IList<userInfo> getlist()         {             IList<userInfo> list = new List<userInfo>();             DataTable dt = GetTable();             foreach (DataRow dr in dt.Rows)             {                 userInfo info = new userInfo();                 info.Id = Convert.ToInt32(dr["id"]);                 info.Name = Convert.ToString(dr["name"]);                 info.Age = Convert.ToInt32(dr["age"]);                 info.Sex = Convert.ToString(dr["sex"]);                   list.Add(info);             }             return list;         }


GridView

C# code?123456     public class GridView<T> where T : class,new()     {         public IEnumerable<T> rows { get; set; }         public int total;     }


打开以后就是这个样子 请问哪里错了呀??


返回的数据是
{"total":1,"rows":[{"Id":3,"Name":"赵六","Age":17,"Sex":"男"}]}

 { field: 'name', title: '名字', width: 100 }
改成{ field: 'Name', title: '年龄', width: 100 }
所有名字要一样,大小写区分

设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©youerw.com 优尔论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。