【问题标题】:ASP.NET Can not Change Visibility of a Formview controlASP.NET 无法更改 Formview 控件的可见性
【发布时间】:2009-10-08 16:57:26
【问题描述】:

我觉得这很愚蠢,但到底是什么......

这是处理下拉列表事件的两行方法:

        resolve = (Button)FormView1.FindControl("btn_resolve");
        resolve.Visible = true;

以前它曾经和我一起工作过!现在不工作了

【问题讨论】:

  • 怎么不工作了?作为一个附带问题,我倾向于将我的操作包装在我用 FindControl 找到的控件上,如果没有找到Control is nothing block...

标签: c# .net asp.net events formview


【解决方案1】:

你需要使用 formview 数据绑定事件,比如

 protected void FormView1_DataBound(object sender, EventArgs e)
{
    if (FormView1.CurrentMode == FormViewMode.Edit)
    {
        btn_resolve = (Button)FormView1.FindControl("btn_resolve");
        resolve.Visible = true;
    }
}

【讨论】:

  • 谢谢 Mo,我只是通过向 formview 添加数据绑定事件并根据我的算法更改了 if 语句
猜你喜欢
  • 2017-12-23
  • 2011-04-21
  • 1970-01-01
  • 2012-09-28
  • 1970-01-01
  • 1970-01-01
  • 2023-04-09
  • 2019-08-28
  • 1970-01-01
相关资源
最近更新 更多