如何访问FormView中的控件
1个回答
2014-12-24
展开全部
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{
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{
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询