调拨代码汇总

 一、合并单元格

 

private  DataTable CreateDataTable()
        {
            DataTable dt 
=   new  DataTable();
            dt.Columns.Add(
" Year " );
            dt.Columns.Add(
" Term " );
            dt.Columns.Add(
" Course " );
            dt.Columns.Add(
" Teacher " );
            dt.Columns.Add(
" Score " );
            dt.Columns.Add(
" Remark " );

            dt.Rows.Add(
" 2010年 " " 第一学期 " " 语文 " " 张三 " " 75 " " 及格 " );
            dt.Rows.Add(
" 2010年 " " 第一学期 " " 数学 " " 李四 " " 85 " " 良好 " );
            dt.Rows.Add(
" 2010年 " " 第二学期 " " 语文 " " 李四 " " 75 " " 及格 " );
            dt.Rows.Add(
" 2010年 " " 第二学期 " " 数学 " " 李四 " " 95 " " 优秀 " );
            dt.Rows.Add(
" 2010年 " " 第二学期 " " 政治 " " 李四 " " 57 " " 不及格 " );

            
return  dt;
        }

        
private   void  BindGrid()
        {
            grdScore.DataSource 
=  CreateDataTable();
            grdScore.DataBind();
            GroupGridView(grdScore, 
new   int [] {  0 1 3  });
        }

        
private   void  GroupGridView(GridView gv,  int [] rowCounts)
        {
            
string  strContent;
            
int  i;
            
int  count;
            
int  rowSpanCount;

            
foreach  ( int  rowCount  in  rowCounts)
            {
                strContent 
=   string .Empty;
                i 
=   0 ;
                count 
=   0 ;
                rowSpanCount 
=   2 ;

                
foreach  (GridViewRow row  in  gv.Rows)
                {

                    
if  (strContent  ==  row.Cells[rowCount].Text)
                    {
                        gv.Rows[count 
-   1 ].Cells[rowCount].RowSpan  =  rowSpanCount ++ ;
                        gv.Rows[i].Cells[rowCount].Visible 
=   false ;
                    }
                    
else
                    {
                        rowSpanCount 
=   2 ;
                        count 
=  i  +   1 ;
                    }
                    strContent 
=  row.Cells[rowCount].Text;

                    i
++ ;
                }
            }
        }

 

 

二、页面打印

 

window.print(); //简单又好用

 

三、Gridview中链接直接弹出页面

 

         < asp:GridView  ID ="GridView1"  runat ="server"  AutoGenerateColumns ="False"  
            BackColor
="White"  BorderColor ="#3366CC"  BorderStyle ="None"  BorderWidth ="1px"  
            CellPadding
="4"  Width ="616px" >
            
< RowStyle  BackColor ="White"  ForeColor ="#003399"   />
            
< Columns >
                
< asp:TemplateField  HeaderText ="编号" >
                    
< ItemTemplate >
                      
< asp:HyperLink  ID ="HyperLink1"  onclick ="javascript: window.open('Default.aspx?Id='+this.innerText+'')"  style ="text-decoration: underline;cursor:hand"  runat ="server" > <% Eval ( " Code " %> </ asp:HyperLink >
                      
<% --    < asp:HyperLink ID = " HyperLink1 "  onclick = " bindData(this.innerText) "  style = " text-decoration: underline;cursor:hand "  runat = " server " >< %#  Eval ( " Code " %> </ asp:HyperLink > --%>
<% --                           < a onclick = " bindData(this.innerText) "  style = " text-decoration: underline;cursor:hand " >< %#  Eval ( " Code " %> </ a > --%>
                    
</ ItemTemplate >
                
</ asp:TemplateField >
                
< asp:BoundField  DataField ="Name"  HeaderText ="名称"   />
                
< asp:BoundField  DataField ="Store"  HeaderText ="所属仓库"   />
                
< asp:BoundField  DataField ="StoreInfo"  HeaderText ="仓管信息"   />
                
< asp:BoundField  DataField ="Number"  HeaderText ="商品数"   />
            
</ Columns >
            
< FooterStyle  BackColor ="#99CCCC"  ForeColor ="#003399"   />
            
< PagerStyle  BackColor ="#99CCCC"  ForeColor ="#003399"  HorizontalAlign ="Left"   />
            
< SelectedRowStyle  BackColor ="#009999"  Font-Bold ="True"  ForeColor ="#CCFF99"   />
            
< HeaderStyle  BackColor ="#003399"  Font-Bold ="True"  ForeColor ="#CCCCFF"   />
        
</ asp:GridView >

 下面的代码是在上边的基础上添加了对IE的控制的

   < asp:HyperLink  ID ="HyperLink1"  onclick ="javascript: window.open('Default.aspx?Id='+this.innerText+'','查看','top=150,left=50,toolbar=no, menubar=no,scrollbars=yes, resizable=no, location=no, status=no, width=850,height=400');"  style ="text-decoration: underline;cursor:hand"  runat ="server" > <% Eval ( " Code " %> </ asp:HyperLink >

 

转载于:https://www.cnblogs.com/kevin-top/archive/2011/06/25/2090275.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值