日期:2014-05-17  浏览次数:20451 次

GridView内表格如何合并,重分求教

如图表1是正常GridView,表2是想要结果,表格的月份列,月份值为相同时表格合并留一个
求指点
GridView 表格合并

------解决方案--------------------
纵向合并gridview单元格的两种方法 
------解决方案--------------------
GridView里的数据是从数据库里读出来的么? 从数据库上下工夫撒!
------解决方案--------------------
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Demo.aspx.cs" Inherits="WebApplication1.Demo" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Tim Demo 演示</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
<asp:GridView ID="GridView1" runat="server" 
onrowdatabound="GridView1_RowDataBound">
</asp:GridView>
    </div>
    </form>
</body>

</html>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Drawing;

namespace WebApplication1
{
public partial class Demo : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindData();
}
}

void BindData()

var list = new List<Temp>
{
new Temp{ SiteName="千灯浦口",Time="2011-9-23",Function=Fun.自动值.ToString(), CODMn="4.10", TOC="6.83",pH="7.10"},
new Temp{ SiteName="千灯浦口",Time="2011-9-23",Function=Fun.手工值.ToString(), CODMn="4.2", TOC="6.34",pH="7.3"},
new Temp{ SiteName="千灯浦口",Time="2011-9-23",Function=Fun.偏差.ToString(), CODMn="-2.38%", TOC="7.73%",pH="-2.74%"},
new Temp{ SiteName="石浦大桥",Time="2011-9-23",Function=Fun.自动值.ToString(), CODMn="3.9", TOC="6.38",pH="7.18"},
new Temp{ SiteName="石浦大桥",Time="2011-9-23",Function=Fun.手工值.ToString(), CODMn="5.1", TOC="6.08",pH="6.99"},
new Temp{ SiteName="石浦大桥",Time="2011-9-23",Function=Fun.偏差.ToString(), CODMn="-23.53%", TOC="4.93%",pH="2.72%"},
new Temp{ SiteName="朱军港口",Time="2011-9-23",Function=Fun.自动值.ToString(), CODMn="3.30", TOC="6.43",pH="6.64"},
new Temp{ SiteName="朱军港口",Time="2011-9-2