zoukankan      html  css  js  c++  java
  • 如何访问Formview中的控件

    .net Framework类库中的FindControl方法可以帮助我们访问Formview中的控件:
    protected void FormView1_ItemCreated(object sender, EventArgs e)   
    {       
        DropDownList test;       
       switch (FormView1.CurrentMode)       
       {           
             case FormViewMode.Edit: 
                test = ((DropDownList)FormView1.Row.FindControl("DropDownList3")); 
                test.Attributes.Add("onchange", "FControl('" + test.UniqueID + "');");    
                break; 
           case FormViewMode.Insert: 
                   test = ((DropDownList)FormView1.Row.FindControl("DropDownList3"));  
                  test.Attributes.Add("onchange", "FControl('" + test.UniqueID + "');");   
                 break;  
          }   
    }

      上面的程序实现的功能是:
    给FormView中的EditItemTemplate和InsertItemTemplate中的DropDownList控件加上FControl;
    FControl方法的代码是:
      function FControl(ctlName)       

               var rowIndex=document.getElementById(ctlName).selectedIndex;
                if(document.getElementById(ctlName).options[rowIndex].innerText=='58')
                {
                    document.getElementById('FControl').style.display="";
                }
                else
                {
                    document.getElementById('FControl').style.display="none"; 
               } 
           }
    当DropDownList的值为58时显示id为FControl的组件,否则不显示。

  • 相关阅读:
    Redis为什么要自己实现一个SDS
    Redis中的数据结构
    编程题
    设计模式-代理模式
    设计模式-原型模式
    设计模式-工厂模式(简单工厂,工厂方法,抽象工厂)
    Redis基础
    Windows提高_1.4进程通信
    Windows提高_1.3文件操作
    Windows提高_1.2遍历进程、遍历模块
  • 原文地址:https://www.cnblogs.com/qfb620/p/1134804.html
Copyright © 2011-2022 走看看