标签:style blog color os 使用 for 数据 div sp
我对控件的依懒是比较少的。有几个控件我比较喜欢用,例如REPEATER显示列表的控件,能提供很大的方便。
使用REPEATER有一个比较方便的功能是通过几句代码就实现了相同项合并单元格合并,这个虽然平时比较少用到,可是有时候客户或者经理比较刁钻的时候,就感觉这个真是好啊!
今天要用AJAX实现一个效果的时候,REPEATER列表控件就没法派上用场,这时我得想办法,根据HTML的一些规律来实现表格相同项的单元格合并。
折腾,终算把效果实现了。备记在这里。
ERP_Reports reprots = new ERP_Reports(); DataTable dtXSSJFX = reprots.GetXSSJFX_DX(txtSDate.Text, txtEDate.Text);//获得销售数据分析报表 if (dtXSSJFX.Rows.Count > 0) { StringBuilder sb = new StringBuilder(); int rowsIndex = 1; for (int i = 0; i < dtXSSJFX.Rows.Count; i++) { if ((i + 1) != dtXSSJFX.Rows.Count) { if (dtXSSJFX.Rows[i]["dlmc"].ToString() == dtXSSJFX.Rows[i + 1]["dlmc"].ToString()) { rowsIndex++; } else { sb.AppendLine("<tr style=\"line-height:24px\" onmouseout=\"this.style.backgroundColor=backupcolor\" onmouseover=\"this.backupcolor=this.style.backgroundColor;this.style.backgroundColor=‘#F1F6FF‘\">"); sb.AppendFormat(" <td rowspan=\"{0}\" style=\"text-align: left; width: 100px; \">{1}</td>", rowsIndex, dtXSSJFX.Rows[i]["dlmc"].ToString()); sb.AppendFormat(" <td style=\"text-align: left; width: 100px; \">{0}</td>", dtXSSJFX.Rows[i + 1 - rowsIndex]["jjmc"].ToString()); sb.AppendFormat(" <td style=\"text-align: left; width: 100px; \">{0}</td>", dtXSSJFX.Rows[i + 1 - rowsIndex]["sl_jm"].ToString()); sb.AppendFormat(" <td style=\"text-align: left; width: 100px; \">{0}</td>", dtXSSJFX.Rows[i + 1 - rowsIndex]["je_jm"].ToString()); sb.AppendFormat(" <td style=\"text-align: left; width: 100px; \">{0}</td>", dtXSSJFX.Rows[i + 1 - rowsIndex]["zb_jm"].ToString()); sb.AppendFormat(" <td style=\"text-align: left; width: 100px; \">{0}</td>", dtXSSJFX.Rows[i + 1 - rowsIndex]["sl_zy"].ToString()); sb.AppendFormat(" <td style=\"text-align: left; width: 100px; \">{0}</td>", dtXSSJFX.Rows[i + 1 - rowsIndex]["je_zy"].ToString()); sb.AppendFormat(" <td style=\"text-align: left; width: 100px; \">{0}</td>", dtXSSJFX.Rows[i + 1 - rowsIndex]["zb_zy"].ToString()); sb.AppendFormat(" <td style=\"text-align: left; width: 100px; \">{0}</td>", dtXSSJFX.Rows[i + 1 - rowsIndex]["sl_hj"].ToString()); sb.AppendFormat(" <td style=\"text-align: left; width: 100px; \">{0}</td>", dtXSSJFX.Rows[i + 1 - rowsIndex]["je_hj"].ToString()); sb.AppendFormat(" <td style=\"text-align: left; width: 100px; \">{0}</td>", dtXSSJFX.Rows[i + 1 - rowsIndex]["zb_hj"].ToString()); sb.AppendLine("</tr>"); for (int j = 1; j < rowsIndex; j++) { sb.AppendLine("<tr style=\"line-height:24px\" onmouseout=\"this.style.backgroundColor=backupcolor\" onmouseover=\"this.backupcolor=this.style.backgroundColor;this.style.backgroundColor=‘#F1F6FF‘\">"); sb.AppendFormat(" <td style=\"text-align: left; width: 100px; \">{0}</td>", dtXSSJFX.Rows[i + 1 - rowsIndex + j]["jjmc"].ToString()); sb.AppendFormat(" <td style=\"text-align: left; width: 100px; \">{0}</td>", dtXSSJFX.Rows[i + 1 - rowsIndex + j]["sl_jm"].ToString()); sb.AppendFormat(" <td style=\"text-align: left; width: 100px; \">{0}</td>", dtXSSJFX.Rows[i + 1 - rowsIndex + j]["je_jm"].ToString()); sb.AppendFormat(" <td style=\"text-align: left; width: 100px; \">{0}</td>", dtXSSJFX.Rows[i + 1 - rowsIndex + j]["zb_jm"].ToString()); sb.AppendFormat(" <td style=\"text-align: left; width: 100px; \">{0}</td>", dtXSSJFX.Rows[i + 1 - rowsIndex + j]["sl_zy"].ToString()); sb.AppendFormat(" <td style=\"text-align: left; width: 100px; \">{0}</td>", dtXSSJFX.Rows[i + 1 - rowsIndex + j]["je_zy"].ToString()); sb.AppendFormat(" <td style=\"text-align: left; width: 100px; \">{0}</td>", dtXSSJFX.Rows[i + 1 - rowsIndex + j]["zb_zy"].ToString()); sb.AppendFormat(" <td style=\"text-align: left; width: 100px; \">{0}</td>", dtXSSJFX.Rows[i + 1 - rowsIndex + j]["sl_hj"].ToString()); sb.AppendFormat(" <td style=\"text-align: left; width: 100px; \">{0}</td>", dtXSSJFX.Rows[i + 1 - rowsIndex + j]["je_hj"].ToString()); sb.AppendFormat(" <td style=\"text-align: left; width: 100px; \">{0}</td>", dtXSSJFX.Rows[i + 1 - rowsIndex + j]["zb_hj"].ToString()); sb.AppendLine("</tr>"); } rowsIndex = 1; } } else { sb.AppendLine("<tr style=\"line-height:24px\" onmouseout=\"this.style.backgroundColor=backupcolor\" onmouseover=\"this.backupcolor=this.style.backgroundColor;this.style.backgroundColor=‘#F1F6FF‘\">"); sb.AppendFormat(" <td style=\"text-align: left; width: 100px; \">{0}</td>", dtXSSJFX.Rows[dtXSSJFX.Rows.Count - 1]["dlmc"].ToString()); sb.AppendFormat(" <td style=\"text-align: left; width: 100px; \">{0}</td>", dtXSSJFX.Rows[dtXSSJFX.Rows.Count - 1]["jjmc"].ToString()); sb.AppendFormat(" <td style=\"text-align: left; width: 100px; \">{0}</td>", dtXSSJFX.Rows[dtXSSJFX.Rows.Count - 1]["sl_jm"].ToString()); sb.AppendFormat(" <td style=\"text-align: left; width: 100px; \">{0}</td>", dtXSSJFX.Rows[dtXSSJFX.Rows.Count - 1]["je_jm"].ToString()); sb.AppendFormat(" <td style=\"text-align: left; width: 100px; \">{0}</td>", dtXSSJFX.Rows[dtXSSJFX.Rows.Count - 1]["zb_jm"].ToString()); sb.AppendFormat(" <td style=\"text-align: left; width: 100px; \">{0}</td>", dtXSSJFX.Rows[dtXSSJFX.Rows.Count - 1]["sl_zy"].ToString()); sb.AppendFormat(" <td style=\"text-align: left; width: 100px; \">{0}</td>", dtXSSJFX.Rows[dtXSSJFX.Rows.Count - 1]["je_zy"].ToString()); sb.AppendFormat(" <td style=\"text-align: left; width: 100px; \">{0}</td>", dtXSSJFX.Rows[dtXSSJFX.Rows.Count - 1]["zb_zy"].ToString()); sb.AppendFormat(" <td style=\"text-align: left; width: 100px; \">{0}</td>", dtXSSJFX.Rows[dtXSSJFX.Rows.Count - 1]["sl_hj"].ToString()); sb.AppendFormat(" <td style=\"text-align: left; width: 100px; \">{0}</td>", dtXSSJFX.Rows[dtXSSJFX.Rows.Count - 1]["je_hj"].ToString()); sb.AppendFormat(" <td style=\"text-align: left; width: 100px; \">{0}</td>", dtXSSJFX.Rows[dtXSSJFX.Rows.Count - 1]["zb_hj"].ToString()); sb.AppendLine("</tr>"); } } litHTMLS.Text = sb.ToString();
标签:style blog color os 使用 for 数据 div sp
原文地址:http://www.cnblogs.com/cxeye/p/3959442.html