源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

asp.net 无刷新分页实例代码

  • 时间:2020-08-10 03:15 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:asp.net 无刷新分页实例代码
数据类代码:
[url=]tr1.append(td); } $("#pageNo").append(tr1); $("#pageNo a").click(function(e){ //页码创建后,就为每一个页码监听一个click事件。 e.preventDefault(); //取消a的默认跳转行为 getPageData($(this).html()); //点击后就去执行取页数据的操作。 }); } }); //---------------------------------------------------------------------------- }); </script> </head> <body> <table>     <tr>         <td>         <ul id="Comment"></ul>         </td>     </tr> </table>     <br />     页数:     <table id="pageNo"></table> </body> </html>
ModelConvertHelper.cs(将datatable转换为list通用类)代码:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections; using System.Data; using System.Reflection; namespace DAL {     public class ModelConvertHelper<T> where T : new ()     {         public static IList<T> ConvertToModel(DataTable dt)         {          IList<T> ts = new List<T>();         Type type=typeof(T);         string tempName = "";         foreach (DataRow dr in dt.Rows)         {             T t = new T();             // 获得此模型的公共属性             PropertyInfo[] propertys = t.GetType().GetProperties();             foreach (PropertyInfo pi in propertys)             {                 tempName = pi.Name;                 // 检查DataTable是否包含此列                 if (dt.Columns.Contains(tempName))                 {                     // 判断此属性是否有Setter                     if (!pi.CanRead) continue;                     object value = dr[tempName];                     if (value != DBNull.Value)                         if (pi.PropertyType == typeof(int))                         {                             pi.SetValue(t, Convert.ToInt32(value), null);                         }                         else if (pi.PropertyType == typeof(string))                         {                             pi.SetValue(t, value.ToString(), null);                         }                         //pi.SetValue(t, value, null);                 }             }             ts.Add(t);         }         return ts;         }         } }
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部