要实现的表头如下:编号,姓名,课程1,课程2,课程3,课程4,课程5,课程6..
注释:
编号和姓名是从B表读出来的..
课程1-课程6 是用A表(课程表)里面读出来的..
如何实现这样的效果?.. 请高手们指教....
注释:
编号和姓名是从B表读出来的..
课程1-课程6 是用A表(课程表)里面读出来的..
如何实现这样的效果?.. 请高手们指教....
解决方案 »
- httpHeader中可以在重定向时新加入字段吗?
- 有用过silverlight的进
- Ie 8 提示 KB927917, IE 6 提示终止操作
- 怎样在另外的页面打开你链接的网页
- HttpPostedFile对象:未将对象引用设置到对象的实例!超级急!
- 实现两个DropdownList的联动,怎么做?好心人帮忙。。。
- 拜托大家帮帮忙啊,请问一下在ASP.NET里面,如何获得存储过程里面的输出参数的值阿??(紧急!!)
- 论坛回复帖子自动识别网址加上链接怎么做?
- 请问一个SQL语句怎么写
- 那如果我想把sql里面的数据写成我规定的xml格式的形式呢,又怎么解决呢?
- 怎么查询空字段!!!!
- 请教水晶报表错位问题,急!!!
1、设置gridView ShowHeader=false;
2、编写gridview 的RowCreated事件:protected void gridView_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
#region 绑定表头
TableCell cell = new TableCell();
//表头行
GridViewRow head = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Normal);
cell = new TableCell();
cell.Text = "编号";
cell.RowSpan = 1;
cell.HorizontalAlign = HorizontalAlign.Center;
head.Cells.Add(cell);
cell = new TableCell();
cell.Text = "姓名";
cell.RowSpan = 1;
cell.HorizontalAlign = HorizontalAlign.Center;
head.Cells.Add(cell); cell = new TableCell();
cell.Text = "课程一";
cell.RowSpan = 1;
cell.HorizontalAlign = HorizontalAlign.Center;
head.Cells.Add(cell);
……//略
……
this.gridView.Controls[0].Controls.AddAt(0, head);
#endregion
}
}
{
switch (e.Row.RowType)
{
//判断是否表头
case DataControlRowType.Header:
//第一行表头
TableCellCollection tcHeader = e.Row.Cells;
tcHeader.Clear(); tcHeader.Add(new TableHeaderCell());
tcHeader[0].Attributes.Add("rowspan", "2");
tcHeader[0].Attributes.Add("bgcolor", "Azure");
tcHeader[0].Text = "用户ID"; tcHeader.Add(new TableHeaderCell());
tcHeader[1].Attributes.Add("colspan", "4");
tcHeader[1].Attributes.Add("bgcolor", "Azure");
tcHeader[1].Text = "基 本 信 息</th></tr><tr>"; //第二行表头
tcHeader.Add(new TableHeaderCell());
tcHeader[2].Attributes.Add("bgcolor", "Azure");
tcHeader[2].Text = "用户姓名";
tcHeader.Add(new TableHeaderCell());
tcHeader[3].Attributes.Add("bgcolor", "Azure");
tcHeader[3].Text = "性别";
tcHeader.Add(new TableHeaderCell());
tcHeader[4].Attributes.Add("bgcolor", "Azure");
tcHeader[4].Text = "家庭住址";
tcHeader.Add(new TableHeaderCell());
tcHeader[5].Attributes.Add("bgcolor", "Azure");
tcHeader[5].Text = "邮政编码";
break;
}
}
<%=(全局变量)%>
select firstname as 姓 from name
....
1 课程1
2 课程2
3 课程3
... ...
B表的数据如下:学员编号 学员姓名 课程名称
001 aaa 课程1
002 bbb 课程1
001 aaa 课程2
001 aaa 课程3
001 aaa 课程4
002 bbb 课程2
002 bbb 课程3
002 bbb 课程4
003 ccc 课程1
003 ccc 课程2
003 ccc 课程3我要显示的效果是:编号 姓名 课程1 课程2 课程3 课程4 课程5 课程6
{
emptyProcess();
}private void emptyProcess()
{
DataTable dt = new DataTable(); DataTable tbl = BLL.LearnPlan.GetSCMInfo(); //获取课程名称 if (tbl != null)
{
DataColumn col = null;
col = new DataColumn("学员编号");
dt.Columns.Add(col);
col = new DataColumn("学员姓名");
dt.Columns.Add(col); foreach (DataRow row in tbl.Rows)
{
col = new DataColumn(row["Course_name"].ToString());
dt.Columns.Add(col);
} GridView1.DataSource = dt;
GridView1.DataBind();
}
}
我这样写... 表头不显示出来....
然后页面代码处理split函数将其分开就行
具体的在网上查一下哈……
(我也是找资料看到你的,就给你一点思路)