土法合并GridView表头


None.gif protected   void  GridView1_RowCreated( object  sender, GridViewRowEventArgs e)
ExpandedBlockStart.gifContractedBlock.gif    
dot.gif {
InBlock.gif        
if (e.Row.RowType == DataControlRowType.Header)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
//因为自定义表头,所以原来系统中实现的排序功能就失效了需自行实现排序功能
InBlock.gif

InBlock.gif            TableCellCollection myTcl 
= e.Row.Cells;
InBlock.gif            
//清除自动生成的表头
InBlock.gif
            myTcl.Clear();
InBlock.gif
InBlock.gif            
//添加新的表头
InBlock.gif
            Label l1 = new Label();
InBlock.gif            l1.Text 
= "序号";
InBlock.gif            myTcl[
0].Controls.Add(l1);
InBlock.gif
InBlock.gif            myTcl.Add(
new TableHeaderCell());
InBlock.gif            myTcl[
1].RowSpan = 2;
InBlock.gif            myTcl[
1].Text = "进口料件</br>品名";
InBlock.gif            myTcl[
1].Width = 150;
InBlock.gif
InBlock.gif            myTcl.Add(
new TableHeaderCell());
InBlock.gif            myTcl[
2].ColumnSpan = 2;
InBlock.gif            myTcl[
2].Text = "成品1";
InBlock.gif
InBlock.gif            myTcl.Add(
new TableHeaderCell());
InBlock.gif            myTcl[
3].ColumnSpan = 2;
InBlock.gif            myTcl[
3].Text = "成品2";
InBlock.gif
InBlock.gif            myTcl.Add(
new TableHeaderCell());
InBlock.gif            myTcl[
4].ColumnSpan = 2;
InBlock.gif            myTcl[
4].Text = "成品3";
InBlock.gif
InBlock.gif            myTcl.Add(
new TableHeaderCell());
InBlock.gif            myTcl[
5].ColumnSpan = 2;
InBlock.gif            myTcl[
5].Text = "成品4";
InBlock.gif
InBlock.gif            myTcl.Add(
new TableHeaderCell());
InBlock.gif            myTcl[
6].ColumnSpan = 2;
InBlock.gif            myTcl[
6].Text = "成品5";
InBlock.gif
InBlock.gif            myTcl.Add(
new TableHeaderCell());
InBlock.gif            myTcl[
7].ColumnSpan = 2;
InBlock.gif            myTcl[
7].Text = "成品6";
InBlock.gif
InBlock.gif            myTcl.Add(
new TableHeaderCell());
InBlock.gif            myTcl[
8].ColumnSpan = 2;
InBlock.gif            myTcl[
8].Text = "成品7";
InBlock.gif
InBlock.gif            myTcl.Add(
new TableHeaderCell());
InBlock.gif            myTcl[
9].ColumnSpan = 2;
InBlock.gif            myTcl[
9].Text = "成品8";
InBlock.gif
InBlock.gif            myTcl.Add(
new TableHeaderCell());
InBlock.gif            myTcl[
10].RowSpan = 2;
InBlock.gif            myTcl[
10].Text = "操作";
InBlock.gif
InBlock.gif            
//以下为新增第二行标题,原理有些类似于SQL注入攻击
InBlock.gif
            myTcl.Add(new TableHeaderCell());
InBlock.gif            myTcl[
11].ColumnSpan = 1;
InBlock.gif            myTcl[
11].Text = "<tr><th>单耗</th><th>损耗</th><th>单耗</th><th>损耗</th><th>单耗</th><th>损耗</th><th>单耗</th><th>损耗</th><th>单耗</th><th>损耗</th><th>单耗</th><th>损耗</th><th>单耗</th><th>损耗</th><th>单耗</th><th>损耗</th>";
InBlock.gif
ExpandedSubBlockEnd.gif        }

ExpandedBlockEnd.gif    }

None.gif

转载于:https://www.cnblogs.com/Fortunelee/archive/2006/12/01/579097.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值