// GridView自动编号 protected void GridView1_RowDataBound( object sender, GridViewRowEventArgs e) ... { if (e.Row.RowType == DataControlRowType.DataRow) ...{ e.Row.Cells[0].Text = (e.Row.DataItemIndex + 1).ToString(); } } // 合并表头 protected void GridView1_RowCreated( object sender, GridViewRowEventArgs e) ... { switch (e.Row.RowType) ...{ case DataControlRowType.Header: //第一行表头 TableCellCollection tcHeader = e.Row.Cells; tcHeader.Clear(); tcHeader.Add(new TableHeaderCell()); tcHeader[0].Attributes.Add("bgcolor", "White"); tcHeader[0].Attributes.Add("colspan", "4"); //跨Column //tcHeader[0].Attributes.Add("align", "left"); tcHeader[0].Text = "产品列表</th></tr><tr>"; break; } }