62,047
社区成员
发帖
与我相关
我的任务
分享
<asp:GridView ID="gv_EmployeeP" runat="server" AutoGenerateColumns="False"
OnRowDataBound="gv_OrderInfo_RowDataBound">
<Columns>
<asp:BoundField DataField="客服" HeaderText="客服" ReadOnly="True">
<HeaderStyle Font-Bold="True" />
<ItemStyle Width="40px" />
</asp:BoundField>
<asp:BoundField DataField="今日总共" HeaderText="总共" ReadOnly="True">
<HeaderStyle Font-Bold="True" />
<ItemStyle Width="40px" />
</asp:BoundField>
<asp:BoundField DataField="今日已到" HeaderText="已到" ReadOnly="True">
<HeaderStyle Font-Bold="True" />
<ItemStyle Width="40px" />
</asp:BoundField>
<asp:BoundField DataField="今日未到" HeaderText="未到" ReadOnly="True">
<HeaderStyle Font-Bold="True" />
<ItemStyle Width="40px" />
</asp:BoundField>
<asp:BoundField DataField="昨日总共" HeaderText="总共" ReadOnly="True">
<HeaderStyle Font-Bold="True" />
<ItemStyle Width="40px" />
</asp:BoundField>
<asp:BoundField DataField="昨日已到" HeaderText="已到" ReadOnly="True">
<HeaderStyle Font-Bold="True" />
<ItemStyle Width="40px" />
</asp:BoundField>
<asp:BoundField DataField="昨日未到" HeaderText="未到" ReadOnly="True">
<HeaderStyle Font-Bold="True" />
<ItemStyle Width="40px" />
</asp:BoundField>
<asp:BoundField DataField="昨日总共" HeaderText="总共" ReadOnly="True">
<HeaderStyle Font-Bold="True" />
<ItemStyle Width="40px" />
</asp:BoundField>
</Columns>
</asp:GridView>
private DataTable OneSelfData(DataTable _dt)
{
DataTable dt = new DataTable("Table_OneSelf");
dt.Columns.Add("客服", System.Type.GetType("System.String"));
dt.Columns.Add("今日总共", System.Type.GetType("System.Int32"));
dt.Columns.Add("今日已到", System.Type.GetType("System.Int32"));
dt.Columns.Add("今日未到", System.Type.GetType("System.Int32"));
dt.Columns.Add("昨日总共", System.Type.GetType("System.Int32"));
//。。省略
DataRow dr = dt.NewRow();
//中间代码省略
dt.Rows.Add(dr);
return dt;
}
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm4.aspx.cs" Inherits="WebTest.WebForm4" %>
<!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></title>
</head>
<body>
<form id="form1" runat="server">
<asp:GridView ID="gv_EmployeeP" runat="server" AutoGenerateColumns="False"
OnRowDataBound="gv_OrderInfo_RowDataBound"
onrowcreated="gv_EmployeeP_RowCreated">
<Columns>
<asp:BoundField DataField="客服" HeaderText="客服" ReadOnly="True">
<HeaderStyle Font-Bold="True" />
<ItemStyle Width="40px" />
</asp:BoundField>
<asp:BoundField DataField="今日总共" HeaderText="总共" ReadOnly="True">
<HeaderStyle Font-Bold="True" />
<ItemStyle Width="40px" />
</asp:BoundField>
<asp:BoundField DataField="今日已到" HeaderText="已到" ReadOnly="True">
<HeaderStyle Font-Bold="True" />
<ItemStyle Width="40px" />
</asp:BoundField>
<asp:BoundField DataField="今日未到" HeaderText="未到" ReadOnly="True">
<HeaderStyle Font-Bold="True" />
<ItemStyle Width="40px" />
</asp:BoundField>
<asp:BoundField DataField="昨日总共" HeaderText="总共" ReadOnly="True">
<HeaderStyle Font-Bold="True" />
<ItemStyle Width="40px" />
</asp:BoundField>
<asp:BoundField DataField="昨日已到" HeaderText="已到" ReadOnly="True">
<HeaderStyle Font-Bold="True" />
<ItemStyle Width="40px" />
</asp:BoundField>
<asp:BoundField DataField="昨日未到" HeaderText="未到" ReadOnly="True">
<HeaderStyle Font-Bold="True" />
<ItemStyle Width="40px" />
</asp:BoundField>
<asp:BoundField DataField="昨日总共" HeaderText="总共" ReadOnly="True">
<HeaderStyle Font-Bold="True" />
<ItemStyle Width="40px" />
</asp:BoundField>
</Columns>
</asp:GridView>
</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;
namespace WebTest
{
public partial class WebForm4 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.gv_EmployeeP.DataSource = this.OneSelfData(null);
this.gv_EmployeeP.DataBind();
}
private DataTable OneSelfData(DataTable _dt)
{
DataTable dt = new DataTable("Table_OneSelf");
dt.Columns.Add("客服", System.Type.GetType("System.String"));
dt.Columns.Add("今日总共", System.Type.GetType("System.Int32"));
dt.Columns.Add("今日已到", System.Type.GetType("System.Int32"));
dt.Columns.Add("今日未到", System.Type.GetType("System.Int32"));
dt.Columns.Add("昨日总共", System.Type.GetType("System.Int32"));
dt.Columns.Add("昨日已到", System.Type.GetType("System.Int32"));
dt.Columns.Add("昨日未到", System.Type.GetType("System.Int32"));
//。。省略
DataRow dr = dt.NewRow();
dr[0] = "测试0";
dr[1] = 1;
dr[2] = 2;
dr[3] = 3;
dr[4] = 4;
dr[5] = 5;
dr[6] = 6;
dt.Rows.Add(dr);
DataRow dr1 = dt.NewRow();
dr1[0] = "测试1";
dr1[1] = 0;
dr1[2] = 0;
dr1[3] = 0;
dr1[4] = 0;
dr1[5] = 0;
dr1[6] = 0;
dt.Rows.Add(dr1);
return dt;
}
protected void gv_OrderInfo_RowDataBound(object sender, GridViewRowEventArgs e)
{
}
protected void gv_EmployeeP_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType== DataControlRowType.Header)
{
e.Row.Cells[0].Text="<tr><th>客服</th>" +
" <th colspan='3'>今日</th>" +
" <th colspan='3'>昨日</th>" +
" <th >呵呵</th>" +
" </tr>" +
"<tr><td>客服";
}
}
}
}