< div id = " listTitle " style = " width: 100% " class = " bgblue " > < ul > < li style = " width: 30px; text-align: center; float: left; " class = " bgblue " > 选择 </ li > < asp:Label ID = " c1 " runat = " server " ></ asp:Label > < asp:Label ID = " c2 " runat = " server " ></ asp:Label > < asp:Label ID = " c3 " runat = " server " ></ asp:Label > < asp:Label ID = " c4 " runat = " server " ></ asp:Label > < asp:Label ID = " c5 " runat = " server " ></ asp:Label > < asp:Label ID = " c6 " runat = " server " ></ asp:Label > < asp:Label ID = " c7 " runat = " server " ></ asp:Label > < asp:Label ID = " c8 " runat = " server " ></ asp:Label > < asp:Label ID = " c9 " runat = " server " ></ asp:Label > < asp:Label ID = " c10 " runat = " server " ></ asp:Label > </ ul > </ div > < div id = " joblist " > < asp:Repeater ID = " resume " runat = " server " > < ItemTemplate > < div style = " width: 100% " class = " navlist " id = ' <%# DataBinder.Eval(Container.DataItem, "ResumeID") %> ' > < ul > < li style = " width: 30px; text-align: center; float: left; " > < input type = " checkbox " name = " checkbox " style = " cursor: hand " value = " <%# DataBinder.Eval(Container.DataItem, " id " ) %> " keyid = ' <%# DataBinder.Eval(Container.DataItem, "id") %> ' url = ' <%# DataBinder.Eval(Container.DataItem, "url") %> '" '> </ li > < asp:Label ID = " column1 " runat = " server " ></ asp:Label > < asp:Label ID = " column2 " runat = " server " ></ asp:Label > < asp:Label ID = " column3 " runat = " server " ></ asp:Label > < asp:Label ID = " column4 " runat = " server " ></ asp:Label > < asp:Label ID = " column5 " runat = " server " ></ asp:Label > < asp:Label ID = " column6 " runat = " server " ></ asp:Label > < asp:Label ID = " column7 " runat = " server " ></ asp:Label > < asp:Label ID = " column8 " runat = " server " ></ asp:Label > < asp:Label ID = " column9 " runat = " server " ></ asp:Label > < asp:Label ID = " column10 " runat = " server " ></ asp:Label > </ ul > </ div > </ ItemTemplate > </ asp:Repeater > </ div >
后台代码实现: 1 using System; 2 using System.Collections; 3 using System.Configuration; 4 using System.Data; 5 using System.Linq; 6 using System.Web; 7 using System.Web.Security; 8 using System.Web.UI; 9 using System.Web.UI.HtmlControls; 10 using System.Web.UI.WebControls; 11 using System.Web.UI.WebControls.WebParts; 12 using System.Xml.Linq; 13 14 using System.Text; 15 using System.Reflection; 16 using System.Collections.Generic; 17 using System.Resources; 18 19 public partial class _Receive : PageBase 20 { 21 /**//// <summary> 22 /// 初始默认值(显示列的字段)(数组) 23 /// </summary> 24 private string[] columns = new string[] { 25 "IsSee",//是否查看 +1 26 "JobSeekerName",//求职者姓名 +2 27 "Jobname",//职位名称 +3 28 "WorkYear",//工作年限 +4 29 "NowCityCodevalue",//所在地址 +5 30 "Degreevalue",//学历 +6 31 "CreateDate",//创建日期 +7 32 "SystemLeach",//系统过滤 33 "Assess",//简历评估 34 "Photo"//相片 35 }; 36 37 private string[] CheckedRequestString = new string[]{ 38 "JOBId",//职位id 39 "pjno",//折叠 40 "menuid",//套红 41 "positionid",//职位夹id 42 "summarystyleid",//列表显示样式 43 "workyear",//工作年限 44 "address",//地址 45 "degree",//学历 46 "tradeid",//行业id 47 "job",//岗位id 48 "sex",//性别 49 "vocationalid",//专业 50 "time",//日期 51 "wy", 52 "szdz", 53 "xl" 54 }; 55 56 /**//// <summary> 57 /// 初始默认值(显示列的字段) 58 /// </summary> 59 private string seachShowColumns = PageBase.GetDefaultColumnCode(PageBase.PageTableNo.Receive.ToString()); 60 61 /**//// <summary> 62 /// 初始排序字段 63 /// </summary> 64 private string sortColumn = "CreateDate"; 65 /**//// <summary> 66 /// 初始排序的方式 67 /// </summary> 68 private string sortDirection = "ASC"; 69 70 protected void Page_Load(object sender, EventArgs e) 71 { 72 if (!this.IsPostBack) 73 { 74 this.ddlDatabind(); 75 this.InitColumns(); 76 this.GetReceiveDatabind(); 77 78 /**//// 79 this.txtwork.Value = System.DateTime.Now.ToString("yyyy-MM-dd"); 80 /**//// 81 } 82 } 83 数据列表加载#region 数据列表加载 84 85 /**//// <summary> 86 /// pageload的时候加载列表头 87 /// </summary> 88 private void InitColumns(){ 89 PageTableProfileBAL ptpb; 90 PageTableProfileBAL.GetInstance(out ptpb); 91 List<PageTableProfile> ptp = ptpb.GetPageTableProfileByColmn(UserID, PageBase.PageTableNo.Receive.ToString()); 92 93 string keycontent = ptp.Count == 1 && ptp[0].SeachShowColumns != "" ? ptp[0].SeachShowColumns : this.SeachShowColumns; 94 95 //string CheckedColumnReplace = "SendStatus,IsSee,IsFavOrBuy,"; 96 //if (keycontent.IndexOf(CheckedColumnReplace) == -1) 97 // keycontent = CheckedColumnReplace + keycontent; 98 99 /**////modfiy by john on 2008-05-24 100 ///加上需要显示的图片信息。 定义当前的图片以及还原位置.101 string CheckedColumnReplace = "IsSee,SystemLeach,Assess,Photo,";102 if (keycontent.IndexOf(CheckedColumnReplace) == -1)103 keycontent = CheckedColumnReplace + keycontent;104105 string keycontentcopyto = "";106107 foreach (string defaultcolumnkey in this.columns)108 { 109 if (keycontent.IndexOf(defaultcolumnkey) > -1)110 { 111 keycontentcopyto += defaultcolumnkey + ",";112 }113 }114 keycontent = keycontentcopyto.TrimEnd(',');115116 columns = ResizeColumns(keycontent.Split(",".ToCharArray()));117 string virtualPath = Page.Request.ApplicationPath + "/Receive.aspx";118119 for (int i = 0; i < columns.Length; i++)120 { 121 ContentPlaceHolder cp = (ContentPlaceHolder)Master.FindControl("content_plane");122 Label label = cp.FindControl("c" + (i + 1)) as Label;123 label.Text = CreateHeaderColumn(GetColumnText(virtualPath, columns[i]), columns[i]);124 }125 }126127 /**//// <summary>128 /// 获得列表显示字段的描述129 /// </summary>130 /// <param name="virtualPath"></param>131 /// <param name="columnName"></param>132 /// <returns></returns>133 private string GetColumnText(string virtualPath, string columnName)134 { 135 /**////modify john at 2008-05-29 136 ///手动识别资源文字137 return HttpContext.GetLocalResourceObject(virtualPath, "Column_" + columnName).ToString() == "创建时间" ? "更新日期" : HttpContext.GetLocalResourceObject(virtualPath, "Column_" + columnName).ToString();138 }139140 /**//// <summary>141 /// 创建列表头部142 /// </summary>143 /// <param name="text"></param>144 /// <param name="columnName"></param>145 /// <returns></returns>146 private string CreateHeaderColumn(string text, string columnName)147 { 148 StringBuilder sb = new StringBuilder();149150 if (columnName == "SystemLeach" || columnName == "IsSee" || columnName == "Assess" || columnName == "Photo") /**////图标的特殊形式处理151 { 152 sb.AppendFormat("<li style=\"width:16px;text-align: center;float: left;\" class=\"bgblue\">");153 sb.Append("</li>");154 }155 else156 { 157 158 /**////标签标准形式的处理159 sb.AppendFormat("<li style=\"width:{ 0}px;text-align: center;float: left;\" class=\"bgblue\">", GetColumnWidth(columnName, this.columns.Length));160 sb.AppendFormat("<img src=\"{ 0}\" width=\"7\" height=\"4\" hspace=\"4\" border=\"0\" align=\"absmiddle\"/>", GetSortImageName(columnName));161 sb.AppendFormat("<a href='#' class='dark2' id='{1}' οnclick=tableSort(this,'{2}')>{0}</a>", text, columnName, this.sortDirection);162 sb.Append("</li>");163 break;164 165 }166 return sb.ToString();167 }168169170 /**//// <summary>171 /// 排序显示相对应的image172 /// </summary>173 /// <param name="columnName"></param>174 /// <returns></returns>175 private string GetSortImageName(string columnName)176 { 177 if (this.sortColumn == columnName)178 { 179 if (this.sortDirection == "ASC")180 { 181 //return "jian.gif";182 return "http://xxxxx/App_Themes/default/jobseekers/images/desc.gif";183 }184 else185 { 186 //return "up.gif";187 return "http://xxxxxx/App_Themes/default/jobseekers/images/asc.gif";188 }189 }190 else191 { 192 return "http://xxxxxx/App_Themes/default/jobseekers/images/up.gif";193 }194 }195196 /**//// <summary>197 /// 得到需要显示的列的个数198 /// </summary>199 /// <param name="columns"></param>200 /// <returns></returns>201 private string[] ResizeColumns(string[] columns)202 { 203 string[] cc = null;204 if (columns.Length > 11)205 { 206 cc = new string[11];207 for (int i = 0; i < 11; i++)208 { 209 cc[i] = columns[i];210 }211 }212 else213 { 214 cc = columns;215 }216 return cc;217 }218219 /**//// <summary>220 /// 得到列表与头部标签的宽度221 /// </summary>222 /// <param name="columnName"></param>223 /// <param name="columnCount"></param>224 /// <returns></returns>225 private string GetColumnWidth(string columnName, int columnCount)226 { 227 int tablewidth = 705,width = 0,length = this.columns.Length-4;tablewidth = 705 - (16 * 4) - 30;228 width = tablewidth / length;229 return width.ToString();230 }231232 /**//// <summary>233 /// 数据访问,绑定列表集234 /// </summary>235 public void GetReceiveDatabind()236 { 237 FavoriteBAL frb;238 FavoriteBAL.GetInstance(out frb);239 List<Favorite> fr = new List<Favorite>();240 241 sortColumn = this.__sortorder.Value;242 sortColumn = sortColumn == string.Empty ? "CompanyID" : sortColumn;243 string orderdesc = sortColumn + " " + sortDirection;244245 this.pager1.PageUrl = CheckedRequest();246247 int RecordCount = 0;248 pager1.PageSize = getPageSize() == 0 ? 20 : getPageSize();249 fr = frb.GetFavoriteSequence(search() + searchkey() , pager1.CurrentPageIndex,orderdesc, true, ref RecordCount, pager1.PageSize, true,false);250251 pager1.RecordCount = RecordCount;252 this..DataSource = fr;253 this..ItemDataBound += new RepeaterItemEventHandler(_ItemDataBound);254 this..DataBind();255 }256257 protected int getPageSize()258 { 259 PageTableProfileBAL ptpb;260 PageTableProfileBAL.GetInstance(out ptpb);261 List<PageTableProfile> ptp = ptpb.GetPageTableProfileByColmn(UserID, PageBase.PageTableNo.Receive.ToString());262 int pagesizeinit = 0;263 if (ptp.Count == 1)264 pagesizeinit = ptp[0].SearchResultPageSize;265 return pagesizeinit;266 }267268 /**//// <summary>269 /// 循环读取设置列表值270 /// </summary>271 /// <param name="sender"></param>272 /// <param name="e"></param>273 void _ItemDataBound(object sender, RepeaterItemEventArgs e)274 { 275 RepeaterItem item = e.Item;276 Favorite fr = item.DataItem as Favorite;277 for (int i = 0; i < columns.Length; i++)278 { 279 Label label1 = item.FindControl("column" + (i + 1)) as Label;280 label1.Text = GetValue(fr, i);281 }282 }283284 /**//// <summary>285 /// 获得列表显示相应的字段值286 /// </summary>287 /// <param name="fr"></param>288 /// <param name="index"></param>289 /// <returns></returns>290 private string GetValue(Favorite fr, int index)291 { 292 if (index > columns.Length || index == -1) return "";293 PropertyInfo info = fr.GetType().GetProperty(columns[index].ToString());294 string text = string.Empty;295 if (info.GetValue(fr, null) != null)296 { 297 text = info.GetValue(fr, null).ToString();298 }299 StringBuilder sb = new StringBuilder();300301 if (columns[index].Equals("SystemLeach") || columns[index].Equals("IsSee") || columns[index].Equals("Assess") || columns[index].Equals("Photo"))302 { 303 sb.AppendFormat("<li style=\"width:16px;text-align: center;float: left;\">");//class=\"" + columns[index] + "\"304 switch (columns[index])305 { 306 case "SystemLeach":307 sb.AppendFormat("{0}", "<img src=\"http://xxx/v5/images/03525520.gif\" width=\"16\" height=\"16\" />");308 break;309 case "IsSee":310 sb.AppendFormat("{0}", "<img src=\"http://xxx/v5/images/17_03.gif\" width=\"16\" height=\"16\" />");311 break;312 case "Assess":313 sb.AppendFormat("{0}", "<img src=\"http://xxx/v5/images/17_01.gif\" width=\"16\" height=\"16\" />");314 break;315 case "Photo":316 sb.AppendFormat("{0}", "<img src=\"http://xxx/v5/images/17_04.gif\" width=\"16\" height=\"16\" />");317 break;318 }319 320 sb.Append("</li>");321 }322 else323 { 324 sb.AppendFormat("<li style=\"width:{ 0}px;text-align: center;float: left; overflow:hidden;'>\">", GetColumnWidth(columns[index], this.columns.Length));//class=\"" + columns[index] + "\"325 if (columns[index].Equals("CreateDate"))326 text = Convert.ToDateTime(text).ToString("yyyy-MM-dd");327 if (columns[index].Equals("WorkYear"))328 { 329 if (text == "0")330 text = "应届毕业";331 else332 text += "年";333 }334 sb.AppendFormat("{0}", text);335 sb.Append("</li>");336 }337 return sb.ToString();338 }339 #endregion340341 设置需要查询的条件#region 设置需要查询的条件342343 private string search()344 { 345 return "delstatus != " + (int)PageBase.DelStatus.Yes + " and status = " + (int)PageBase.Status.Receive + " and userid = '" + UserID + "'";346 }347348349 350 #endregion351352 353354 自定义属性#region 自定义属性355356 private List<Favorite> FavoriteTable357 { 358 get359 { 360 return ViewState["FavoriteTable"] as List<Favorite>;361 }362 set363 { 364 ViewState["FavoriteTable"] = value;365 }366 }367368 public string SeachShowColumns369 { 370 get { return this.seachShowColumns; }371372 set373 { 374 if (!string.IsNullOrEmpty(value))375 { 376 this.seachShowColumns = value;377 }378 }379 }380 protected void btnsort_Click(object sender, EventArgs e)381 { 382 sortColumn = this.__sortorder.Value;383 sortDirection = this.__sortDir.Value;384385 this.InitColumns();386 this.GetReceiveDatabind();387 }388389 #endregion390} 391