在RowDataBound中改变或设置Header和Footer

  1. protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) 
  2.     { 
  3.         if (e.Row.RowType == DataControlRowType.Footer) 
  4.         { 
  5.             e.Row.Cells[0].Text = "21"
  6.             e.Row.Cells[1].Text = "All"
  7.             e.Row.Cells[2].Text = "Total Dealers Status"
  8.             //e.Row.Cells[4].Text = Convert.ToInt32(HidCount.Value).ToString("###,###"); 
  9.             //e.Row.Cells[6].Text = Convert.ToDouble(HidSoldPrice.Value).ToString("C"); 
  10.             e.Row.Cells[2].HorizontalAlign = HorizontalAlign.Right; 
  11.            //e.Row.Cells[4].HorizontalAlign = HorizontalAlign.Right; 
  12.             //e.Row.Cells[6].HorizontalAlign = HorizontalAlign.Right; 
  13.  
  14.             //e.Row.Cells[7].Text = DateTime.Now.ToString("yyyy-MM-dd"); 
  15.             //e.Row.Cells[8].Text = DateTime.Now.ToString(@"HH:mm:ss G/MT zzz"); 
  16.         } 
  17.         if (e.Row.RowType == DataControlRowType.DataRow) 
  18.         { 
  19.              
  20.             e.Row.Cells[3].Attributes.Add("style""vnd.ms-excel.numberformat: @"); 
  21.             //e.Row.Cells[4].Attributes.Add("style", "vnd.ms-excel.numberformat: @"); 
  22.              
  23.         } 
  24.         if (e.Row.RowType == DataControlRowType.Header) 
  25.         { 
  26.  
  27.             
  28.             GridViewRow row = new GridViewRow(-1, -1, DataControlRowType.Header, 
  29. DataControlRowState.Normal); 
  30.              
  31.             TableCell cell1 = new TableCell(); 
  32.             cell1.Text = "<b>Report:</b>"
  33.             row.Cells.AddAt(0, cell1); 
  34.  
  35.             TableCell cell2 = new TableCell(); 
  36.             cell2.Text = "New Loans By Deal"
  37.             row.Cells.AddAt(1, cell2); 
  38.  
  39.             TableCell cell3 = new TableCell(); 
  40.             cell3.Attributes["align"] = "right"
  41.             cell3.Text = "<font style=/"text-align:right; font-
  42. weight:bold;/">Date/Time:</font>"
  43.             row.Cells.AddAt(2, cell3); 
  44.  
  45.  
  46.  
  47.             //TableCell cell4 = new TableCell(); 
  48.             //cell4.Text = DateTime.Now.ToString("yyyy-MM-dd") + " " + 
  49. DateTime.Now.ToString(@"HH:mm:ss"); 
  50.             //row.Cells.AddAt(3, cell4); 
  51.             
  52.  
  53.             GridView1.Controls[0].Controls.AddAt(0, row); 
  54.         } 
  55.     } 
  56. }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值