• 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

  • 相关阅读:
    (转) Nova是如何统计OpenStack资源
    (转) 一次批量重启引发的Neutron网络故障
    (转)理解Keystone的四种Token
    neutron 虚拟机网络问题调试
    转 Nova: 虚机的块设备总结 [Nova Instance Block Device]
    kvm 客户机系统的代码是如何运行的
    12 while循环
    11猜拳游戏
    10 if 嵌套
    09 if...elif..else语句
  • 原文地址:https://www.cnblogs.com/songsh96/p/1030968.html
Copyright © 2020-2023  润新知