三层合并 分组单元格, 使用Gridview实现 (前后台)
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GradeManagement.aspx.cs"
Inherits="PandaRG.NB.OurSchoolWeb.WebApplication.SchoolManagement.GradeManage.GradeManagement"
Theme="Management" %>
<%@ Register Src="GradeControl.ascx" TagName="GradeControl" TagPrefix="uc1" %>
<!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 id="Head1" runat="server">
<title>学习阶段_年级_班级管理首页</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script type="text/javascript" src="http://www.cnblogs.com/JS/common.js"></script>
<script type="text/javascript" src="http://www.cnblogs.com/JS/subModal.js"></script>
<script type="text/javascript">
function CloseWindow()
{
window.opener = null;
window.open('', '_self');
window.close();
}
function SelectAll(tempControl)
{
var theBox = tempControl; //获取参数名称
sState = theBox.checked; //查看参数是否为真
elem = theBox.form.elements; //获取当前页面所有元素
for (i = 0; i < elem.length; i++)
{
if (elem[i].type == "checkbox" && elem[i].id != theBox.id)
{
if (elem[i].checked != sState)
{
elem[i].click();
}
}
}
}
function SelectDelete()
{
var objtb = window.document.getElementById('GridViewGradeGroup');
if (objtb != null)
{
var rownum = objtb.rows.length;
for (var i = 1; i < rownum; i++)
{
checkbox = objtb.rows[i].cells[0].children[0];
if (checkbox != null)
{
if (checkbox.type = "checkbox")
{
if (checkbox.checked == true)
{
if (window.confirm('您确定要删除这些信息吗?') == 1)
{
return true;
}
else
{
window.event.returnValue = false;
return false;
}
}
}
}
}
window.alert('请您选择要删除的记录!');
window.event.returnValue = false;
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="Sm" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div class="divDicManageTitle">
学习阶段_年级_班级管理首页</div>
<br />
<br />
<div class="divDicManageCommandOpertion">
<asp:Button ID="ButtonAdd" runat="server" Text="增加" SkinID="ShortButtonSkin" OnClick="ButtonAdd_Click" />
<asp:Button ID="ButtonDelete" runat="server" Text="删除" SkinID="ShortButtonSkin" OnClick="ButtonDelete_Click" />
</div>
<br />
<br />
<br />
<div class="divDicManageGridView">
<asp:GridView ID="GridViewGradeGroup" runat="server" SkinID="GridViewSkin" AutoGenerateColumns="False"
DataKeyNames="GradeGroupId" AllowPaging="false" OnRowDataBound="GridViewGradeGroup_RowDataBound">
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<asp:CheckBox ID="CheckBox2" runat="server" onclick="javascript:SelectAll(this);"
Text="全选" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="ItemCheckBox" Text='<%# Eval("GradeGroupId") %>' runat="server" />
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="62px" />
<HeaderStyle Font-Bold="True" HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField HeaderText=" ">
<ItemTemplate>
<asp:HyperLink runat="server" ID="HyperLinkEdit" Text="编辑"></asp:HyperLink>
<%-- <a href="#" onclick="showPopWin('编辑学习阶段','AddGrade.aspx?CodeKey=<%# Eval("GradeGroupId") %>', 460, 260, null);">
编辑</a>--%>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" Width="60px" />
</asp:TemplateField>
<asp:BoundField DataField="GradeGroupName" HeaderText="学习阶段" HtmlEncode="False">
<ItemStyle HorizontalAlign="Center" Width="200px" VerticalAlign="Middle" />
<HeaderStyle HorizontalAlign="Center" Font-Bold="true" />
</asp:BoundField>
<asp:TemplateField>
<HeaderTemplate>
学制时长</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="LabelGradeGroupYear" runat="server" Text='<%# Eval("GradeGroupYear") %>'></asp:Label></ItemTemplate>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="62px" />
<HeaderStyle Font-Bold="True" HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
升级时间</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="LabelGradeRiseTime" runat="server" Text='<%# Eval("GradeRiseTime") %>'></asp:Label></ItemTemplate>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="62px" />
<HeaderStyle Font-Bold="True" HorizontalAlign="Center" />
</asp:TemplateField>
<%--add Grade UserControl--%>
<asp:BoundField DataField="GradeName" HeaderText="年级" HtmlEncode="False">
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle HorizontalAlign="Center" Width="100px" Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="GradeYear" HeaderText="学制第几年" HtmlEncode="False">
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle HorizontalAlign="Center" Width="100px" Wrap="False" />
</asp:BoundField>
<asp:TemplateField HeaderText="班级">
<ItemTemplate>
<asp:Label ID="LabelClassName" runat="server" Text='<%# Eval("ClassName") %>'></asp:Label></ItemTemplate>
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle Width="100px" HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField HeaderText="班级显示顺序">
<ItemTemplate>
<asp:Label ID="LabelDisplayOrder" runat="server" Text='<%# Eval("DisplayOrder") %>'></asp:Label></ItemTemplate>
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle Width="100px" HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField HeaderText="状态">
<ItemTemplate>
<asp:Label ID="LabelIsClose" runat="server" Text='<%# Eval("IsClose") %>'></asp:Label></ItemTemplate>
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle Width="100px" HorizontalAlign="Center" />
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
<%--display empty table--%>
<table cellpadding="1" cellspacing="0" class="table_bordercolor" id="gvCode" style="background-color: Transparent;
border-color: #BFE5FF; font-family: Arial; font-size: 12px;">
<tr>
<td colspan="5">
<table class="table_bordercolor" cellspacing="0" cellpadding="2" style="background-color: Transparent;
border-color: #BFE5FF; font-family: Arial; font-size: 12px;">
<tr class="table_titlebgcolor" style="font-size: 12px; font-weight: normal; height: 20px;">
<th scope="col" style="width: 60px;">
<input type="checkbox" /><label>全选</label>
</th>
<th scope="col" style="width: 60px;">
</th>
<th align="center" scope="col" style="font-weight: bold; width: 200px;">
学习阶段
</th>
<th align="center" scope="col" style="font-weight: bold; width: 62px;">
学制时长
</th>
<th align="center" scope="col" style="font-weight: bold; width: 62px;">
升级时间
</th>
</tr>
<tr>
<td colspan="6">
<div>
无记录</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</EmptyDataTemplate>
</asp:GridView>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>
代码
代码
Inherits="PandaRG.NB.OurSchoolWeb.WebApplication.SchoolManagement.GradeManage.GradeManagement"
Theme="Management" %>
<%@ Register Src="GradeControl.ascx" TagName="GradeControl" TagPrefix="uc1" %>
<!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 id="Head1" runat="server">
<title>学习阶段_年级_班级管理首页</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script type="text/javascript" src="http://www.cnblogs.com/JS/common.js"></script>
<script type="text/javascript" src="http://www.cnblogs.com/JS/subModal.js"></script>
<script type="text/javascript">
function CloseWindow()
{
window.opener = null;
window.open('', '_self');
window.close();
}
function SelectAll(tempControl)
{
var theBox = tempControl; //获取参数名称
sState = theBox.checked; //查看参数是否为真
elem = theBox.form.elements; //获取当前页面所有元素
for (i = 0; i < elem.length; i++)
{
if (elem[i].type == "checkbox" && elem[i].id != theBox.id)
{
if (elem[i].checked != sState)
{
elem[i].click();
}
}
}
}
function SelectDelete()
{
var objtb = window.document.getElementById('GridViewGradeGroup');
if (objtb != null)
{
var rownum = objtb.rows.length;
for (var i = 1; i < rownum; i++)
{
checkbox = objtb.rows[i].cells[0].children[0];
if (checkbox != null)
{
if (checkbox.type = "checkbox")
{
if (checkbox.checked == true)
{
if (window.confirm('您确定要删除这些信息吗?') == 1)
{
return true;
}
else
{
window.event.returnValue = false;
return false;
}
}
}
}
}
window.alert('请您选择要删除的记录!');
window.event.returnValue = false;
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="Sm" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div class="divDicManageTitle">
学习阶段_年级_班级管理首页</div>
<br />
<br />
<div class="divDicManageCommandOpertion">
<asp:Button ID="ButtonAdd" runat="server" Text="增加" SkinID="ShortButtonSkin" OnClick="ButtonAdd_Click" />
<asp:Button ID="ButtonDelete" runat="server" Text="删除" SkinID="ShortButtonSkin" OnClick="ButtonDelete_Click" />
</div>
<br />
<br />
<br />
<div class="divDicManageGridView">
<asp:GridView ID="GridViewGradeGroup" runat="server" SkinID="GridViewSkin" AutoGenerateColumns="False"
DataKeyNames="GradeGroupId" AllowPaging="false" OnRowDataBound="GridViewGradeGroup_RowDataBound">
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<asp:CheckBox ID="CheckBox2" runat="server" onclick="javascript:SelectAll(this);"
Text="全选" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="ItemCheckBox" Text='<%# Eval("GradeGroupId") %>' runat="server" />
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="62px" />
<HeaderStyle Font-Bold="True" HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField HeaderText=" ">
<ItemTemplate>
<asp:HyperLink runat="server" ID="HyperLinkEdit" Text="编辑"></asp:HyperLink>
<%-- <a href="#" onclick="showPopWin('编辑学习阶段','AddGrade.aspx?CodeKey=<%# Eval("GradeGroupId") %>', 460, 260, null);">
编辑</a>--%>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" Width="60px" />
</asp:TemplateField>
<asp:BoundField DataField="GradeGroupName" HeaderText="学习阶段" HtmlEncode="False">
<ItemStyle HorizontalAlign="Center" Width="200px" VerticalAlign="Middle" />
<HeaderStyle HorizontalAlign="Center" Font-Bold="true" />
</asp:BoundField>
<asp:TemplateField>
<HeaderTemplate>
学制时长</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="LabelGradeGroupYear" runat="server" Text='<%# Eval("GradeGroupYear") %>'></asp:Label></ItemTemplate>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="62px" />
<HeaderStyle Font-Bold="True" HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
升级时间</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="LabelGradeRiseTime" runat="server" Text='<%# Eval("GradeRiseTime") %>'></asp:Label></ItemTemplate>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="62px" />
<HeaderStyle Font-Bold="True" HorizontalAlign="Center" />
</asp:TemplateField>
<%--add Grade UserControl--%>
<asp:BoundField DataField="GradeName" HeaderText="年级" HtmlEncode="False">
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle HorizontalAlign="Center" Width="100px" Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="GradeYear" HeaderText="学制第几年" HtmlEncode="False">
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle HorizontalAlign="Center" Width="100px" Wrap="False" />
</asp:BoundField>
<asp:TemplateField HeaderText="班级">
<ItemTemplate>
<asp:Label ID="LabelClassName" runat="server" Text='<%# Eval("ClassName") %>'></asp:Label></ItemTemplate>
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle Width="100px" HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField HeaderText="班级显示顺序">
<ItemTemplate>
<asp:Label ID="LabelDisplayOrder" runat="server" Text='<%# Eval("DisplayOrder") %>'></asp:Label></ItemTemplate>
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle Width="100px" HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField HeaderText="状态">
<ItemTemplate>
<asp:Label ID="LabelIsClose" runat="server" Text='<%# Eval("IsClose") %>'></asp:Label></ItemTemplate>
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle Width="100px" HorizontalAlign="Center" />
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
<%--display empty table--%>
<table cellpadding="1" cellspacing="0" class="table_bordercolor" id="gvCode" style="background-color: Transparent;
border-color: #BFE5FF; font-family: Arial; font-size: 12px;">
<tr>
<td colspan="5">
<table class="table_bordercolor" cellspacing="0" cellpadding="2" style="background-color: Transparent;
border-color: #BFE5FF; font-family: Arial; font-size: 12px;">
<tr class="table_titlebgcolor" style="font-size: 12px; font-weight: normal; height: 20px;">
<th scope="col" style="width: 60px;">
<input type="checkbox" /><label>全选</label>
</th>
<th scope="col" style="width: 60px;">
</th>
<th align="center" scope="col" style="font-weight: bold; width: 200px;">
学习阶段
</th>
<th align="center" scope="col" style="font-weight: bold; width: 62px;">
学制时长
</th>
<th align="center" scope="col" style="font-weight: bold; width: 62px;">
升级时间
</th>
</tr>
<tr>
<td colspan="6">
<div>
无记录</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</EmptyDataTemplate>
</asp:GridView>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>
后台
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
using System.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using PandaRG.TJ.Common.Log;
using PandaRG.NB.OurSchoolWeb.BusinessLayer;
using System.Reflection;
namespace TestGridView
{
/// <summary>
/// GradeManagement
/// </summary>
public partial class GradeManagement : BasePage
{
/// <summary>
/// Page_Load
/// </summary>
/// <param name="sender">sender</param>
/// <param name="e">e</param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.GridViewGradeGroup.DataSource = BindGradeGroup();
this.GridViewGradeGroup.DataBind();
this.GridViewGradeGroup.RowSpan(new { ColumnIndex = 2, Columns = "3,4" });
this.GridViewGradeGroup.RowSpan(new { ColumnIndex = 5, Columns = "5,6" });
this.GridViewGradeGroup.RowSpan(new { ColumnIndex = 0, ColumnControlID = "ItemCheckBox", Columns = "0,1" });
//this.GridViewGradeGroup.RowSpan(new { ColumnIndex = 0, Columns = "1" }).RowSpan(new { ColumnIndex = 2 }).RowSpan(new { ColumnIndex = 3 }).RowSpan(new { ColumnIndex = 4 }).RowSpan(new { ColumnIndex = 5 }).RowSpan(new { ColumnIndex = 6 });
//Hidden ItemCheckBox value
foreach (GridViewRow row in this.GridViewGradeGroup.Rows)
{
CheckBox ItemCheckBox = (CheckBox)row.FindControl("ItemCheckBox");
if (ItemCheckBox != null)
{
ItemCheckBox.Text = string.Empty;
}
}
this.ButtonDelete.Attributes.Add("onclick", "SelectDelete();");
}
}
/// <summary>
/// BindGradeGroup
/// </summary>
/// <returns></returns>
private DataTable BindGradeGroup()
{
DataTable dtGradeGroup = new GradeManager().GetGrade();
return dtGradeGroup;
}
/// <summary>
/// GridViewGradeGroup_RowDataBound
/// </summary>
/// <param name="sender">sender</param>
/// <param name="e">e</param>
protected void GridViewGradeGroup_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label LabelIsClose = (Label)e.Row.FindControl("LabelIsClose");
if (LabelIsClose != null)
{
if (LabelIsClose.Text.ToUpper() == "FALSE")
{
LabelIsClose.Text = "正常";
}
else
{
LabelIsClose.Text = "关闭";
}
}
//Format date style
Label LabelGradeRiseTime = (Label)e.Row.FindControl("LabelGradeRiseTime");
if (LabelGradeRiseTime != null)
{
DateTime dtGradeRiseTime = DateTime.Parse(LabelGradeRiseTime.Text);
LabelGradeRiseTime.Text = dtGradeRiseTime.Month + "月" + dtGradeRiseTime.Day + "日";
}
HyperLink Edit = (HyperLink)e.Row.FindControl("HyperLinkEdit");
Edit.NavigateUrl = "AddGrade.aspx?FUNC=EDIT";
}
}
/// <summary>
/// AddDeleteCodeToViewState
/// </summary>
private void AddDeleteCodeToViewState()
{
Dictionary<string, int> selectRowD;
if (ViewState["SelectDeal"] == null)
{
selectRowD = new Dictionary<string, int>();
ViewState.Add("SelectDeal", selectRowD);
}
else
{
selectRowD = (Dictionary<string, int>)ViewState["SelectDeal"];
}
CheckBox cb;
foreach (GridViewRow gvr in GridViewGradeGroup.Rows)
{
cb = (CheckBox)gvr.Cells[0].FindControl("ItemCheckBox");
if (cb.Checked)
{
if (!selectRowD.ContainsKey(GridViewGradeGroup.PageIndex.ToString() + gvr.RowIndex.ToString()))
{
selectRowD.Add(GridViewGradeGroup.PageIndex.ToString() + gvr.RowIndex.ToString(), Convert.ToInt32(GridViewGradeGroup.DataKeys[gvr.RowIndex][0]));
}
}
else
{
if (selectRowD.ContainsKey(GridViewGradeGroup.PageIndex.ToString() + gvr.RowIndex.ToString()))
{
selectRowD.Remove(GridViewGradeGroup.PageIndex.ToString() + gvr.RowIndex.ToString());
}
}
}
}
/// <summary>
/// ButtonDelete_Click
/// </summary>
/// <param name="sender">sender</param>
/// <param name="e">e</param>
protected void ButtonDelete_Click(object sender, EventArgs e)
{
this.AddDeleteCodeToViewState();
Dictionary<string, int> selectRowD = ViewState["SelectDeal"] == null ? new Dictionary<string, int>() : (Dictionary<string, int>)ViewState["SelectDeal"];
if (selectRowD.Count != 0)
{
System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
foreach (int s in selectRowD.Values)
{
stringBuilder.Append(s.ToString());
//new DataDictionaryManager().(s, true);
}
ViewState.Remove("SelectDeal");
string jsreload = "alert('删除成功!');window.location.reload();";
ScriptManager.RegisterStartupScript(this, this.GetType(), "reloadInfo", jsreload, true);
for (int i = 0; i < GridViewGradeGroup.Rows.Count; i++)
{
GridViewRow gvr = GridViewGradeGroup.Rows[i];
int keyValue = Convert.ToInt32(GridViewGradeGroup.DataKeys[i].Value.ToString());
Label lblCodeTypeId = (Label)gvr.FindControl("lblCodeTypeId");
CheckBox chkIsSelect = (CheckBox)gvr.FindControl("ItemCheckBox");
if (chkIsSelect.Checked)
{
//Record Log
OurSchoolWebHelper.WriteLog(UserID, "删除学习阶段_年级_班级", lblCodeTypeId.Text, keyValue, gvr.Cells[2].Text);
}
}
}
}
protected void ButtonAdd_Click(object sender, EventArgs e)
{
Response.Redirect("AddGrade.aspx");
}
}
public static class GridViewExtensions
{
/// <summary>
/// RowSpan
/// </summary>
/// <param name="gridview">gridview</param>
/// <param name="field">field</param>
/// <returns></returns>
public static GridView RowSpan(this GridView gridview, object field)
{
Dictionary<string, string> rowDictionary = ObjectLoadDictionary(field);
int columnIndex = int.Parse(rowDictionary["ColumnIndex"]);
string columnName = rowDictionary["ColumnControlID"];
string propertyName = rowDictionary["PropertyName"];
string columns = rowDictionary["Columns"];
for (var i = 0; i < gridview.Rows.Count; i++)
{
int keyValue = Convert.ToInt32(gridview.DataKeys[i].Value.ToString());
int rowSpanCount = 1;
for (int j = i + 1; j < gridview.Rows.Count; j++)
{
int keyValueNext = Convert.ToInt32(gridview.DataKeys[j].Value.ToString());
if (string.IsNullOrEmpty(columnName))
{
if (gridview.Rows[i].Cells[columnIndex].Text == gridview.Rows[j].Cells[columnIndex].Text)
{
rowSpanCount++;
if (keyValue == keyValueNext)
{
gridview.Rows[j].Cells[columnIndex].Visible = false;
}
if (!string.IsNullOrEmpty(columns))
{
columns.Split(',').ToList<string>().ForEach(c => gridview.Rows[j].Cells[int.Parse(c)].Visible = false);
}
}
else
{
break;
}
}
else
{
//模板行的合并处理
if (GetPropertyValue(gridview.Rows[i].Cells[columnIndex].FindControl(columnName), propertyName).ToString() == GetPropertyValue(gridview.Rows[j].Cells[columnIndex].FindControl(columnName), propertyName).ToString())
{
rowSpanCount++;
if (keyValue == keyValueNext)
{
//隐藏相同的行
gridview.Rows[j].Cells[columnIndex].Visible = false;
}
if (!string.IsNullOrEmpty(columns))
{
columns.Split(',').ToList<string>().ForEach(c => gridview.Rows[j].Cells[int.Parse(c)].Visible = false);
}
}
else
{
break;
}
}
}
if (rowSpanCount > 1)
{
//行合并
gridview.Rows[i].Cells[columnIndex].RowSpan = rowSpanCount;
//判断是否有额外的行需要合并
if (!string.IsNullOrEmpty(columns))
{
//额外的行合并
columns.Split(',').ToList<string>().ForEach(c => gridview.Rows[i].Cells[int.Parse(c)].RowSpan = rowSpanCount);
}
i = i + rowSpanCount - 1;
}
}
return gridview;
}
private static Dictionary<string, string> ObjectLoadDictionary(object fields)
{
Dictionary<string, string> resultDictionary = new Dictionary<string, string>();
PropertyInfo[] property = fields.GetType().GetProperties(BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.GetProperty);
foreach (PropertyInfo tempProperty in property)
{
resultDictionary.Add(tempProperty.Name, tempProperty.GetValue(fields, null).ToString());
}
//指定默认值
if (!resultDictionary.Keys.Contains("ColumnIndex"))
{
throw new Exception("未指定要合并行的索引 ColumnIndex 属性!");
}
if (!resultDictionary.Keys.Contains("ColumnControlID"))
{
resultDictionary.Add("ColumnControlID", null);
}
if (!resultDictionary.Keys.Contains("PropertyName"))
{
resultDictionary.Add("PropertyName", "Text");
}
if (!resultDictionary.Keys.Contains("Columns"))
{
resultDictionary.Add("Columns", null);
}
return resultDictionary;
}
/// <summary>
/// 获取一个对象的一个属性..
/// </summary>
/// <param name="obj"></param>
/// <param name="PropertyName">属性名称</param>
/// <returns>属性的值, 如果无法获取则返回null</returns>
private static object GetPropertyValue(object obj, string PropertyName)
{
PropertyInfo property = obj.GetType().GetProperty(PropertyName);
return property.GetValue(obj, null);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using PandaRG.TJ.Common.Log;
using PandaRG.NB.OurSchoolWeb.BusinessLayer;
using System.Reflection;
namespace TestGridView
{
/// <summary>
/// GradeManagement
/// </summary>
public partial class GradeManagement : BasePage
{
/// <summary>
/// Page_Load
/// </summary>
/// <param name="sender">sender</param>
/// <param name="e">e</param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.GridViewGradeGroup.DataSource = BindGradeGroup();
this.GridViewGradeGroup.DataBind();
this.GridViewGradeGroup.RowSpan(new { ColumnIndex = 2, Columns = "3,4" });
this.GridViewGradeGroup.RowSpan(new { ColumnIndex = 5, Columns = "5,6" });
this.GridViewGradeGroup.RowSpan(new { ColumnIndex = 0, ColumnControlID = "ItemCheckBox", Columns = "0,1" });
//this.GridViewGradeGroup.RowSpan(new { ColumnIndex = 0, Columns = "1" }).RowSpan(new { ColumnIndex = 2 }).RowSpan(new { ColumnIndex = 3 }).RowSpan(new { ColumnIndex = 4 }).RowSpan(new { ColumnIndex = 5 }).RowSpan(new { ColumnIndex = 6 });
//Hidden ItemCheckBox value
foreach (GridViewRow row in this.GridViewGradeGroup.Rows)
{
CheckBox ItemCheckBox = (CheckBox)row.FindControl("ItemCheckBox");
if (ItemCheckBox != null)
{
ItemCheckBox.Text = string.Empty;
}
}
this.ButtonDelete.Attributes.Add("onclick", "SelectDelete();");
}
}
/// <summary>
/// BindGradeGroup
/// </summary>
/// <returns></returns>
private DataTable BindGradeGroup()
{
DataTable dtGradeGroup = new GradeManager().GetGrade();
return dtGradeGroup;
}
/// <summary>
/// GridViewGradeGroup_RowDataBound
/// </summary>
/// <param name="sender">sender</param>
/// <param name="e">e</param>
protected void GridViewGradeGroup_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label LabelIsClose = (Label)e.Row.FindControl("LabelIsClose");
if (LabelIsClose != null)
{
if (LabelIsClose.Text.ToUpper() == "FALSE")
{
LabelIsClose.Text = "正常";
}
else
{
LabelIsClose.Text = "关闭";
}
}
//Format date style
Label LabelGradeRiseTime = (Label)e.Row.FindControl("LabelGradeRiseTime");
if (LabelGradeRiseTime != null)
{
DateTime dtGradeRiseTime = DateTime.Parse(LabelGradeRiseTime.Text);
LabelGradeRiseTime.Text = dtGradeRiseTime.Month + "月" + dtGradeRiseTime.Day + "日";
}
HyperLink Edit = (HyperLink)e.Row.FindControl("HyperLinkEdit");
Edit.NavigateUrl = "AddGrade.aspx?FUNC=EDIT";
}
}
/// <summary>
/// AddDeleteCodeToViewState
/// </summary>
private void AddDeleteCodeToViewState()
{
Dictionary<string, int> selectRowD;
if (ViewState["SelectDeal"] == null)
{
selectRowD = new Dictionary<string, int>();
ViewState.Add("SelectDeal", selectRowD);
}
else
{
selectRowD = (Dictionary<string, int>)ViewState["SelectDeal"];
}
CheckBox cb;
foreach (GridViewRow gvr in GridViewGradeGroup.Rows)
{
cb = (CheckBox)gvr.Cells[0].FindControl("ItemCheckBox");
if (cb.Checked)
{
if (!selectRowD.ContainsKey(GridViewGradeGroup.PageIndex.ToString() + gvr.RowIndex.ToString()))
{
selectRowD.Add(GridViewGradeGroup.PageIndex.ToString() + gvr.RowIndex.ToString(), Convert.ToInt32(GridViewGradeGroup.DataKeys[gvr.RowIndex][0]));
}
}
else
{
if (selectRowD.ContainsKey(GridViewGradeGroup.PageIndex.ToString() + gvr.RowIndex.ToString()))
{
selectRowD.Remove(GridViewGradeGroup.PageIndex.ToString() + gvr.RowIndex.ToString());
}
}
}
}
/// <summary>
/// ButtonDelete_Click
/// </summary>
/// <param name="sender">sender</param>
/// <param name="e">e</param>
protected void ButtonDelete_Click(object sender, EventArgs e)
{
this.AddDeleteCodeToViewState();
Dictionary<string, int> selectRowD = ViewState["SelectDeal"] == null ? new Dictionary<string, int>() : (Dictionary<string, int>)ViewState["SelectDeal"];
if (selectRowD.Count != 0)
{
System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
foreach (int s in selectRowD.Values)
{
stringBuilder.Append(s.ToString());
//new DataDictionaryManager().(s, true);
}
ViewState.Remove("SelectDeal");
string jsreload = "alert('删除成功!');window.location.reload();";
ScriptManager.RegisterStartupScript(this, this.GetType(), "reloadInfo", jsreload, true);
for (int i = 0; i < GridViewGradeGroup.Rows.Count; i++)
{
GridViewRow gvr = GridViewGradeGroup.Rows[i];
int keyValue = Convert.ToInt32(GridViewGradeGroup.DataKeys[i].Value.ToString());
Label lblCodeTypeId = (Label)gvr.FindControl("lblCodeTypeId");
CheckBox chkIsSelect = (CheckBox)gvr.FindControl("ItemCheckBox");
if (chkIsSelect.Checked)
{
//Record Log
OurSchoolWebHelper.WriteLog(UserID, "删除学习阶段_年级_班级", lblCodeTypeId.Text, keyValue, gvr.Cells[2].Text);
}
}
}
}
protected void ButtonAdd_Click(object sender, EventArgs e)
{
Response.Redirect("AddGrade.aspx");
}
}
public static class GridViewExtensions
{
/// <summary>
/// RowSpan
/// </summary>
/// <param name="gridview">gridview</param>
/// <param name="field">field</param>
/// <returns></returns>
public static GridView RowSpan(this GridView gridview, object field)
{
Dictionary<string, string> rowDictionary = ObjectLoadDictionary(field);
int columnIndex = int.Parse(rowDictionary["ColumnIndex"]);
string columnName = rowDictionary["ColumnControlID"];
string propertyName = rowDictionary["PropertyName"];
string columns = rowDictionary["Columns"];
for (var i = 0; i < gridview.Rows.Count; i++)
{
int keyValue = Convert.ToInt32(gridview.DataKeys[i].Value.ToString());
int rowSpanCount = 1;
for (int j = i + 1; j < gridview.Rows.Count; j++)
{
int keyValueNext = Convert.ToInt32(gridview.DataKeys[j].Value.ToString());
if (string.IsNullOrEmpty(columnName))
{
if (gridview.Rows[i].Cells[columnIndex].Text == gridview.Rows[j].Cells[columnIndex].Text)
{
rowSpanCount++;
if (keyValue == keyValueNext)
{
gridview.Rows[j].Cells[columnIndex].Visible = false;
}
if (!string.IsNullOrEmpty(columns))
{
columns.Split(',').ToList<string>().ForEach(c => gridview.Rows[j].Cells[int.Parse(c)].Visible = false);
}
}
else
{
break;
}
}
else
{
//模板行的合并处理
if (GetPropertyValue(gridview.Rows[i].Cells[columnIndex].FindControl(columnName), propertyName).ToString() == GetPropertyValue(gridview.Rows[j].Cells[columnIndex].FindControl(columnName), propertyName).ToString())
{
rowSpanCount++;
if (keyValue == keyValueNext)
{
//隐藏相同的行
gridview.Rows[j].Cells[columnIndex].Visible = false;
}
if (!string.IsNullOrEmpty(columns))
{
columns.Split(',').ToList<string>().ForEach(c => gridview.Rows[j].Cells[int.Parse(c)].Visible = false);
}
}
else
{
break;
}
}
}
if (rowSpanCount > 1)
{
//行合并
gridview.Rows[i].Cells[columnIndex].RowSpan = rowSpanCount;
//判断是否有额外的行需要合并
if (!string.IsNullOrEmpty(columns))
{
//额外的行合并
columns.Split(',').ToList<string>().ForEach(c => gridview.Rows[i].Cells[int.Parse(c)].RowSpan = rowSpanCount);
}
i = i + rowSpanCount - 1;
}
}
return gridview;
}
private static Dictionary<string, string> ObjectLoadDictionary(object fields)
{
Dictionary<string, string> resultDictionary = new Dictionary<string, string>();
PropertyInfo[] property = fields.GetType().GetProperties(BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.GetProperty);
foreach (PropertyInfo tempProperty in property)
{
resultDictionary.Add(tempProperty.Name, tempProperty.GetValue(fields, null).ToString());
}
//指定默认值
if (!resultDictionary.Keys.Contains("ColumnIndex"))
{
throw new Exception("未指定要合并行的索引 ColumnIndex 属性!");
}
if (!resultDictionary.Keys.Contains("ColumnControlID"))
{
resultDictionary.Add("ColumnControlID", null);
}
if (!resultDictionary.Keys.Contains("PropertyName"))
{
resultDictionary.Add("PropertyName", "Text");
}
if (!resultDictionary.Keys.Contains("Columns"))
{
resultDictionary.Add("Columns", null);
}
return resultDictionary;
}
/// <summary>
/// 获取一个对象的一个属性..
/// </summary>
/// <param name="obj"></param>
/// <param name="PropertyName">属性名称</param>
/// <returns>属性的值, 如果无法获取则返回null</returns>
private static object GetPropertyValue(object obj, string PropertyName)
{
PropertyInfo property = obj.GetType().GetProperty(PropertyName);
return property.GetValue(obj, null);
}
}
}
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GradeManagement.aspx.cs"
Inherits="PandaRG.NB.OurSchoolWeb.WebApplication.SchoolManagement.GradeManage.GradeManagement"
Theme="Management" %>
<%@ Register Src="GradeControl.ascx" TagName="GradeControl" TagPrefix="uc1" %>
<!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 id="Head1" runat="server">
<title>学习阶段_年级_班级管理首页</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script type="text/javascript" src="http://www.cnblogs.com/JS/common.js"></script>
<script type="text/javascript" src="http://www.cnblogs.com/JS/subModal.js"></script>
<script type="text/javascript">
function CloseWindow()
{
window.opener = null;
window.open('', '_self');
window.close();
}
function SelectAll(tempControl)
{
var theBox = tempControl; //获取参数名称
sState = theBox.checked; //查看参数是否为真
elem = theBox.form.elements; //获取当前页面所有元素
for (i = 0; i < elem.length; i++)
{
if (elem[i].type == "checkbox" && elem[i].id != theBox.id)
{
if (elem[i].checked != sState)
{
elem[i].click();
}
}
}
}
function SelectDelete()
{
var objtb = window.document.getElementById('GridViewGradeGroup');
if (objtb != null)
{
var rownum = objtb.rows.length;
for (var i = 1; i < rownum; i++)
{
checkbox = objtb.rows[i].cells[0].children[0];
if (checkbox != null)
{
if (checkbox.type = "checkbox")
{
if (checkbox.checked == true)
{
if (window.confirm('您确定要删除这些信息吗?') == 1)
{
return true;
}
else
{
window.event.returnValue = false;
return false;
}
}
}
}
}
window.alert('请您选择要删除的记录!');
window.event.returnValue = false;
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="Sm" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div class="divDicManageTitle">
学习阶段_年级_班级管理首页</div>
<br />
<br />
<div class="divDicManageCommandOpertion">
<asp:Button ID="ButtonAdd" runat="server" Text="增加" SkinID="ShortButtonSkin" OnClick="ButtonAdd_Click" />
<asp:Button ID="ButtonDelete" runat="server" Text="删除" SkinID="ShortButtonSkin" OnClick="ButtonDelete_Click" />
</div>
<br />
<br />
<br />
<div class="divDicManageGridView">
<asp:GridView ID="GridViewGradeGroup" runat="server" SkinID="GridViewSkin" AutoGenerateColumns="False"
DataKeyNames="GradeGroupId" AllowPaging="false" OnRowDataBound="GridViewGradeGroup_RowDataBound">
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<asp:CheckBox ID="CheckBox2" runat="server" onclick="javascript:SelectAll(this);"
Text="全选" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="ItemCheckBox" Text='<%# Eval("GradeGroupId") %>' runat="server" />
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="62px" />
<HeaderStyle Font-Bold="True" HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField HeaderText=" ">
<ItemTemplate>
<asp:HyperLink runat="server" ID="HyperLinkEdit" Text="编辑"></asp:HyperLink>
<%-- <a href="#" onclick="showPopWin('编辑学习阶段','AddGrade.aspx?CodeKey=<%# Eval("GradeGroupId") %>', 460, 260, null);">
编辑</a>--%>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" Width="60px" />
</asp:TemplateField>
<asp:BoundField DataField="GradeGroupName" HeaderText="学习阶段" HtmlEncode="False">
<ItemStyle HorizontalAlign="Center" Width="200px" VerticalAlign="Middle" />
<HeaderStyle HorizontalAlign="Center" Font-Bold="true" />
</asp:BoundField>
<asp:TemplateField>
<HeaderTemplate>
学制时长</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="LabelGradeGroupYear" runat="server" Text='<%# Eval("GradeGroupYear") %>'></asp:Label></ItemTemplate>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="62px" />
<HeaderStyle Font-Bold="True" HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
升级时间</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="LabelGradeRiseTime" runat="server" Text='<%# Eval("GradeRiseTime") %>'></asp:Label></ItemTemplate>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="62px" />
<HeaderStyle Font-Bold="True" HorizontalAlign="Center" />
</asp:TemplateField>
<%--add Grade UserControl--%>
<asp:BoundField DataField="GradeName" HeaderText="年级" HtmlEncode="False">
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle HorizontalAlign="Center" Width="100px" Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="GradeYear" HeaderText="学制第几年" HtmlEncode="False">
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle HorizontalAlign="Center" Width="100px" Wrap="False" />
</asp:BoundField>
<asp:TemplateField HeaderText="班级">
<ItemTemplate>
<asp:Label ID="LabelClassName" runat="server" Text='<%# Eval("ClassName") %>'></asp:Label></ItemTemplate>
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle Width="100px" HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField HeaderText="班级显示顺序">
<ItemTemplate>
<asp:Label ID="LabelDisplayOrder" runat="server" Text='<%# Eval("DisplayOrder") %>'></asp:Label></ItemTemplate>
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle Width="100px" HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField HeaderText="状态">
<ItemTemplate>
<asp:Label ID="LabelIsClose" runat="server" Text='<%# Eval("IsClose") %>'></asp:Label></ItemTemplate>
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle Width="100px" HorizontalAlign="Center" />
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
<%--display empty table--%>
<table cellpadding="1" cellspacing="0" class="table_bordercolor" id="gvCode" style="background-color: Transparent;
border-color: #BFE5FF; font-family: Arial; font-size: 12px;">
<tr>
<td colspan="5">
<table class="table_bordercolor" cellspacing="0" cellpadding="2" style="background-color: Transparent;
border-color: #BFE5FF; font-family: Arial; font-size: 12px;">
<tr class="table_titlebgcolor" style="font-size: 12px; font-weight: normal; height: 20px;">
<th scope="col" style="width: 60px;">
<input type="checkbox" /><label>全选</label>
</th>
<th scope="col" style="width: 60px;">
</th>
<th align="center" scope="col" style="font-weight: bold; width: 200px;">
学习阶段
</th>
<th align="center" scope="col" style="font-weight: bold; width: 62px;">
学制时长
</th>
<th align="center" scope="col" style="font-weight: bold; width: 62px;">
升级时间
</th>
</tr>
<tr>
<td colspan="6">
<div style="text-align: center">
无记录</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</EmptyDataTemplate>
</asp:GridView>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>
Inherits="PandaRG.NB.OurSchoolWeb.WebApplication.SchoolManagement.GradeManage.GradeManagement"
Theme="Management" %>
<%@ Register Src="GradeControl.ascx" TagName="GradeControl" TagPrefix="uc1" %>
<!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 id="Head1" runat="server">
<title>学习阶段_年级_班级管理首页</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script type="text/javascript" src="http://www.cnblogs.com/JS/common.js"></script>
<script type="text/javascript" src="http://www.cnblogs.com/JS/subModal.js"></script>
<script type="text/javascript">
function CloseWindow()
{
window.opener = null;
window.open('', '_self');
window.close();
}
function SelectAll(tempControl)
{
var theBox = tempControl; //获取参数名称
sState = theBox.checked; //查看参数是否为真
elem = theBox.form.elements; //获取当前页面所有元素
for (i = 0; i < elem.length; i++)
{
if (elem[i].type == "checkbox" && elem[i].id != theBox.id)
{
if (elem[i].checked != sState)
{
elem[i].click();
}
}
}
}
function SelectDelete()
{
var objtb = window.document.getElementById('GridViewGradeGroup');
if (objtb != null)
{
var rownum = objtb.rows.length;
for (var i = 1; i < rownum; i++)
{
checkbox = objtb.rows[i].cells[0].children[0];
if (checkbox != null)
{
if (checkbox.type = "checkbox")
{
if (checkbox.checked == true)
{
if (window.confirm('您确定要删除这些信息吗?') == 1)
{
return true;
}
else
{
window.event.returnValue = false;
return false;
}
}
}
}
}
window.alert('请您选择要删除的记录!');
window.event.returnValue = false;
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="Sm" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div class="divDicManageTitle">
学习阶段_年级_班级管理首页</div>
<br />
<br />
<div class="divDicManageCommandOpertion">
<asp:Button ID="ButtonAdd" runat="server" Text="增加" SkinID="ShortButtonSkin" OnClick="ButtonAdd_Click" />
<asp:Button ID="ButtonDelete" runat="server" Text="删除" SkinID="ShortButtonSkin" OnClick="ButtonDelete_Click" />
</div>
<br />
<br />
<br />
<div class="divDicManageGridView">
<asp:GridView ID="GridViewGradeGroup" runat="server" SkinID="GridViewSkin" AutoGenerateColumns="False"
DataKeyNames="GradeGroupId" AllowPaging="false" OnRowDataBound="GridViewGradeGroup_RowDataBound">
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<asp:CheckBox ID="CheckBox2" runat="server" onclick="javascript:SelectAll(this);"
Text="全选" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="ItemCheckBox" Text='<%# Eval("GradeGroupId") %>' runat="server" />
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="62px" />
<HeaderStyle Font-Bold="True" HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField HeaderText=" ">
<ItemTemplate>
<asp:HyperLink runat="server" ID="HyperLinkEdit" Text="编辑"></asp:HyperLink>
<%-- <a href="#" onclick="showPopWin('编辑学习阶段','AddGrade.aspx?CodeKey=<%# Eval("GradeGroupId") %>', 460, 260, null);">
编辑</a>--%>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" Width="60px" />
</asp:TemplateField>
<asp:BoundField DataField="GradeGroupName" HeaderText="学习阶段" HtmlEncode="False">
<ItemStyle HorizontalAlign="Center" Width="200px" VerticalAlign="Middle" />
<HeaderStyle HorizontalAlign="Center" Font-Bold="true" />
</asp:BoundField>
<asp:TemplateField>
<HeaderTemplate>
学制时长</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="LabelGradeGroupYear" runat="server" Text='<%# Eval("GradeGroupYear") %>'></asp:Label></ItemTemplate>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="62px" />
<HeaderStyle Font-Bold="True" HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
升级时间</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="LabelGradeRiseTime" runat="server" Text='<%# Eval("GradeRiseTime") %>'></asp:Label></ItemTemplate>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="62px" />
<HeaderStyle Font-Bold="True" HorizontalAlign="Center" />
</asp:TemplateField>
<%--add Grade UserControl--%>
<asp:BoundField DataField="GradeName" HeaderText="年级" HtmlEncode="False">
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle HorizontalAlign="Center" Width="100px" Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="GradeYear" HeaderText="学制第几年" HtmlEncode="False">
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle HorizontalAlign="Center" Width="100px" Wrap="False" />
</asp:BoundField>
<asp:TemplateField HeaderText="班级">
<ItemTemplate>
<asp:Label ID="LabelClassName" runat="server" Text='<%# Eval("ClassName") %>'></asp:Label></ItemTemplate>
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle Width="100px" HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField HeaderText="班级显示顺序">
<ItemTemplate>
<asp:Label ID="LabelDisplayOrder" runat="server" Text='<%# Eval("DisplayOrder") %>'></asp:Label></ItemTemplate>
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle Width="100px" HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField HeaderText="状态">
<ItemTemplate>
<asp:Label ID="LabelIsClose" runat="server" Text='<%# Eval("IsClose") %>'></asp:Label></ItemTemplate>
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle Width="100px" HorizontalAlign="Center" />
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
<%--display empty table--%>
<table cellpadding="1" cellspacing="0" class="table_bordercolor" id="gvCode" style="background-color: Transparent;
border-color: #BFE5FF; font-family: Arial; font-size: 12px;">
<tr>
<td colspan="5">
<table class="table_bordercolor" cellspacing="0" cellpadding="2" style="background-color: Transparent;
border-color: #BFE5FF; font-family: Arial; font-size: 12px;">
<tr class="table_titlebgcolor" style="font-size: 12px; font-weight: normal; height: 20px;">
<th scope="col" style="width: 60px;">
<input type="checkbox" /><label>全选</label>
</th>
<th scope="col" style="width: 60px;">
</th>
<th align="center" scope="col" style="font-weight: bold; width: 200px;">
学习阶段
</th>
<th align="center" scope="col" style="font-weight: bold; width: 62px;">
学制时长
</th>
<th align="center" scope="col" style="font-weight: bold; width: 62px;">
升级时间
</th>
</tr>
<tr>
<td colspan="6">
<div style="text-align: center">
无记录</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</EmptyDataTemplate>
</asp:GridView>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>