zoukankan      html  css  js  c++  java
  • GridView数据源为空时,找不到FooterRow

    在GridView的Command事件中可以用下面的语句来找到:

    GridViewRow gridViewRow = ((Control)e.CommandSource).BindingContainer as GridViewRow;
    GridView中控件的事件中,可以用下面的语句来找到:
    GridViewRow gridViewRow = (sender as TextBox).Parent.Parent as GridViewRow;
    string itemNo = ((TextBox)(gridViewRow.FindControl("TextBoxPartNoNew"))).Text.Trim();

    在Page_Load怎么找到,还没有想到?

    下面资料转自:http://www.itzhe.cn/html/web/ASP.NET/20071127/22928_2.html

    用 gridview 实现插入功能时遇到的问题

    // create a new header row 
    GridViewRow headerRow = base.CreateRow(-1-1, DataControlRowType.Header, DataControlRowState.Normal); 
    this.InitializeRow(headerRow, fields); 

    // add the header row to the table 
    table.Rows.Add(headerRow); 


    // create the empty row 
    GridViewRow emptyRow = new GridViewRow(-1-1, DataControlRowType.EmptyDataRow, DataControlRowState.Normal); 
    TableCell cell 
    = new TableCell(); itzhe.cn 
    cell.ColumnSpan 
    = fields.Length; 
    cell.Width 
    = Unit.Percentage(100); 

    // respect the precedence order if both EmptyDataTemplate 
    // and EmptyDataText are both supplied  
    if (this.EmptyDataTemplate != null

    this.EmptyDataTemplate.InstantiateIn(cell); 

    else if (!string.IsNullOrEmpty(this.EmptyDataText)) 

    cell.Controls.Add(
    new LiteralControl(EmptyDataText)); 
    IT 者



    emptyRow.Cells.Add(cell); 
    table.Rows.Add(emptyRow); 

    //if (this.ShowFooterWhenEmpty) 
    //
    // create footer row 
    GridViewRow footerRow = base.CreateRow(-1-1, DataControlRowType.Footer, DataControlRowState.Normal); 
    this.InitializeRow(footerRow, fields); 

    // add the footer to the table 
    table.Rows.Add(footerRow); 
    //

    this.Controls.Clear(); 
    www.itzhe.cn

    this.Controls.Add(table); 
    this.ShowFooter = true

    return rows; 




    功能实现了,没有数据的时候header和footer都能显示,我把插入数据要输入的项目都放在footer里面,所以没有数据的时候,始终会显示一条插入纪录,但当我提交以后,gridView.FooterRow.FindControl( "tb_foot_name ") 返回空值。但假如表格里边本身有数据的话 gridView.FooterRow.FindControl( "tb_foot_name ")能够返回对象,区别是:
    但没有数据时,footer是我自己创建的,有数据时footer是系统创建的。
    请问大家,有何良策

    谢谢
    本篇文章来源于 www.itzhe.cn 原文链接:http://www.itzhe.cn/html/web/ASP.NET/20071127/22928_2.html

  • 相关阅读:
    [转载]三小时学会Kubernetes:容器编排详细指南
    《微服务设计》书摘
    Mac os安装golang开发环境
    openstack-KVM-Network
    openstack-KVM管理工具
    openstack-KVM-vCPU
    openstack-KVM-Memory
    openstack-KVM-存储配置
    openstack-云计算概述
    openstack-KVM安装与使用
  • 原文地址:https://www.cnblogs.com/songsh96/p/1030968.html
Copyright © 2011-2022 走看看