.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的组件,否则不显示。

相关文章:

  • 2021-11-13
  • 2022-12-23
  • 2021-12-25
  • 2021-07-11
  • 2021-08-15
  • 2022-12-23
  • 2022-12-23
  • 2021-09-08
猜你喜欢
  • 2022-01-27
  • 2021-10-08
  • 2021-10-02
  • 2022-12-23
  • 2021-09-14
  • 2022-12-23
相关资源
相似解决方案