在数据列表中启用子控件 [英] Enable Child Control in DataList

查看:54
本文介绍了在数据列表中启用子控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在开发Web应用程序,并使用DataList Control来显示数据.

我在数据列表的ItemTemplate中放置了一个复选框(以及禁用的单选按钮).我希望当我单击复选框时,那些单选按钮将启用.

怎么可能呢?

问候!
Aman

Hi All,

I am working on web application and using DataList Control to show data.

I have placed a checkbox (along with disabled Radio buttons) in ItemTemplate of Data List. I want that when I click on checkbox those Radio Button become enable.

How its possible?

Regards!
Aman

推荐答案

您可以使用JQuery做到这一点.以下是我的工作:

< script type ="text/javascript" src ="jquery-1.6.js"></script>
< html xmlns ="http://www.w3.org/1999/xhtml">
< head runat ="server">
< script type ="text/javascript" language ="javascript">
函数SelectRBTN(chk)
{
You can do it using JQuery. Below is what I did:

<script type="text/javascript" src="jquery-1.6.js"></script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script type="text/javascript" language="javascript">
function SelectRBTN(chk)
{


(''#<%= dataList.ClientID%>'').find("input:checkbox").each(function(){
if(this == chk&& this.value ==``on''){
(''#<%=dataList.ClientID %>'').find("input:checkbox").each(function() {
if (this == chk && this.value == ''on'') {


(this).parent(``td''). children(''input:radio'').attr(''disabled'','''');
}
});
}
</script>
</head>
< body>
< form id ="form1" runat ="server">
< asp:DataList ID ="dataList" runat ="server"
onitemcreated ="dataList_ItemCreated">
< ItemTemplate>
< asp:CheckBox ID ="chk" runat ="server" onclick ="javascript:SelectRBTN(this);"/>
< asp:RadioButton ID ="rbtn1" runat ="server" enabled ="false"/>
< asp:RadioButton ID ="rbtn2" runat ="server" enabled ="false"/>
<%#Eval(名称")%>
<%#Eval("Roll")%>
</ItemTemplate>
</asp:DataList>
</form>
</body>
</html>
(this).parent(''td'').children(''input:radio'').attr(''disabled'', '''');
}
});
}
</script>
</head>
<body >
<form id="form1" runat="server">
<asp:DataList ID="dataList" runat="server"
onitemcreated="dataList_ItemCreated" >
<ItemTemplate>
<asp:CheckBox ID="chk" runat="server" onclick="javascript:SelectRBTN(this);"/>
<asp:RadioButton ID="rbtn1" runat="server" enabled="false" />
<asp:RadioButton ID="rbtn2" runat="server" enabled="false" />
<%#Eval("Name") %>
<%#Eval("Roll")%>
</ItemTemplate>
</asp:DataList>
</form>
</body>
</html>


这篇关于在数据列表中启用子控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆