求助:Datalist控件中ItemTemplate绑定了隐藏的一个按钮,鼠标移动到ItemTemplate单元中,如何显示出来? Datalist控件中ItemTemplate绑定了隐藏的一个按钮,鼠标移动到ItemTemplate单元中,如何显示出来?或者使用层的方式,当鼠标移动到该单元格中,将包含这个按钮的层显示出来?小弟初接触.NET,求各位大神帮忙,谢谢!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <script type="text/javascript"> function hiden(obj) { obj.style.display = "none"; } function show(obj) { obj.style.display = ""; } </script> <div onmousemove ="hiden(this);" onmouseout="show(this)"> <asp:CheckBox ID="CheckBox1" runat="server" onmousemove ="hiden(this);" onmouseout="show(this)" /> </div>你可以在不同的控件里写不同的事件调用这两个方法来控制隐藏或者显示 zifengshen1981兄弟,谢谢但是datalist的模板是从数据库读取数据后自动生成的啊,鼠标移动到单元格怎么显示呢? 不管什么控件,最终都生成 HTML代码,自己分析下代码,然后确定鼠标移动事件绑定在每行的哪个控件上,再在该行找到隐藏的控件,用JS实现其显示或隐藏。建议用Repeater控件 后台找到你要的控件..Button1 注册属性。。Button1.Attributes.Add("onmousemove","hiden(this);") 谢谢各位兄弟,比如我有如下datalist,已经绑定,请问鼠标移动到单元格,怎么把ImageButton1给显示出来?<asp:DataList ID="datalist1" DataKeyField ="id" runat="server" RepeatColumns="8" RepeatDirection="Horizontal" Width="889px" > <ItemTemplate> <table style="width: 95%; height: 193px"> <tr > <td colspan="3" style="height: 21px"> <strong> 商品名称:<%#DataBinder.Eval(Container.DataItem, "name")%></strong></td> </tr> <tr> <td colspan="3" style="height: 25px"> <table style="width: 95%; height: 46px"> <tr> <td rowspan="3" style="width: 91px; height: 45px" align="center"> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~buy.gif" ToolTip="购买" Visible="False" Height="22px" Width="25px" /></td> </tr> </table> </td> </tr> </table> </ItemTemplate> <script type="text/javascript"> function hiden(obj) { document.getElementById(obj).style.display = "none"; //obj.style.display = "none"; } function show(obj) { document.getElementById(obj).style.display = ""; //obj.style.display = ""; } </script><table style="width: 95%; height: 193px" onmousemove="show('imgdiv')" onmouseout="hiden('imgdiv')"> <tr> <td colspan="3" style="height: 21px">商品名称:</td> </tr> <tr> <td colspan="3" style="height: 25px"> <table style="width: 95%; height: 46px"> <tr> <td rowspan="3" style="width: 91px; height: 45px" align="center"> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <div id="imgdiv" style="display:none"> <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~buy.gif" ToolTip="购买" Height="22px" Width="25px" /> </div> </td> </tr> </table> </td> </tr> </table> 这个还只能对层进行控制,不能对img进行控制,如果一开始设置visable = false 那么这个控件都找不到了 谈何去控制。所以只需要对层进行设置即可 可以使用jquery的bind方法,将每一行的mouseover事件绑定到对应单元格,然后再进行控件的显示隐藏操作,不是太难。 非常简单,看好了,我只说一次:第一种方法:通过Repeater这个控件的ItemDataBound这个事件(其它绑定控件也有类似这个控件),获得对应按钮控件的div,并且显示出来。第二种方法:用jquery的类选择器,给你要显示的按钮div标签加上一定的规律,然后$(".class")获得所有按钮的div层,再移动事件里面写$(".class").attr("style","display:block");就能够显示了。 qingfeng_wu熊可能对我说的理解错了,我的并非固定按钮或控件,我是在DataList中的ItemTemplate里面的中增加一个层,这个层当鼠标移动到到该table中,显示层。由于ItemTemplate是个模板,数据绑定后会有许多由该模板生成的单元,当鼠标移动到不同的单元,会显示该单元的层,小弟愚笨,这个还真不好做。 qingfeng_wu熊可能对我说的理解错了,我的并非固定按钮或控件,我是在DataList中的ItemTemplate里面的中增加一个层,这个层当鼠标移动到到该table中,显示层。由于ItemTemplate是个模板,数据绑定后会有许多由该模板生成的单元,当鼠标移动到不同的单元,会显示该单元的层,小弟愚笨,这个还真不好做。我知道你要这个效果,我上面不是说了吗:给你要显示的按钮div标签加上一定的规律,规律是自己加的,然后按照自己的需求去写算法。 GridView 如何 在自动生成列后面 加模板列 客户端只能上内网不能上外网,能不能获取外网ip.c#代码如何实现 无法显示动态的图片 如何保留xml节点的空格 页面变量??????????????? 在线等,一个SQL语句的问题,解决了马上给分! internal server error 高手问题:VB.net和C#开发WEB程序的相互调用!!! 找后台编辑功能代码 怎样在DataGrid中的使用RadioButtonList? 支付宝联合登陆 支付宝反馈回来的sign签名不一致,求解!! UDP发送需要的时间与什么因素有关系?
<script type="text/javascript">
function hiden(obj)
{
obj.style.display = "none";
}
function show(obj)
{
obj.style.display = "";
}
</script>
<div onmousemove ="hiden(this);" onmouseout="show(this)">
<asp:CheckBox ID="CheckBox1" runat="server" onmousemove ="hiden(this);" onmouseout="show(this)" />
</div>你可以在不同的控件里写不同的事件调用这两个方法来控制隐藏或者显示
但是datalist的模板是从数据库读取数据后自动生成的啊,鼠标移动到单元格怎么显示呢?
Button1.Attributes.Add("onmousemove","hiden(this);")
<asp:DataList ID="datalist1" DataKeyField ="id" runat="server" RepeatColumns="8" RepeatDirection="Horizontal" Width="889px" >
<ItemTemplate>
<table style="width: 95%; height: 193px">
<tr >
<td colspan="3" style="height: 21px">
<strong>
商品名称:<%#DataBinder.Eval(Container.DataItem, "name")%></strong></td>
</tr>
<tr>
<td colspan="3" style="height: 25px">
<table style="width: 95%; height: 46px">
<tr>
<td rowspan="3" style="width: 91px; height: 45px" align="center">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~buy.gif" ToolTip="购买"
Visible="False" Height="22px" Width="25px" /></td>
</tr>
</table>
</td>
</tr>
</table>
</ItemTemplate>
<script type="text/javascript">
function hiden(obj) {
document.getElementById(obj).style.display = "none";
//obj.style.display = "none";
}
function show(obj) {
document.getElementById(obj).style.display = "";
//obj.style.display = "";
}
</script>
<table style="width: 95%; height: 193px" onmousemove="show('imgdiv')" onmouseout="hiden('imgdiv')">
<tr>
<td colspan="3" style="height: 21px">商品名称:</td>
</tr>
<tr>
<td colspan="3" style="height: 25px">
<table style="width: 95%; height: 46px">
<tr>
<td rowspan="3" style="width: 91px; height: 45px" align="center">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<div id="imgdiv" style="display:none">
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~buy.gif" ToolTip="购买"
Height="22px" Width="25px" />
</div>
</td> </tr> </table>
</td>
</tr>
</table>
第一种方法:通过Repeater这个控件的ItemDataBound这个事件(其它绑定控件也有类似这个控件),获得对应按钮控件的div,并且显示出来。第二种方法:用jquery的类选择器,给你要显示的按钮div标签加上一定的规律,然后$(".class")获得所有按钮的div层,再移动事件里面写$(".class").attr("style","display:block");就能够显示了。
qingfeng_wu熊可能对我说的理解错了,我的并非固定按钮或控件,我是在DataList中的ItemTemplate里面的中增加一个层,这个层当鼠标移动到到该table中,显示层。由于ItemTemplate是个模板,数据绑定后会有许多由该模板生成的单元,当鼠标移动到不同的单元,会显示该单元的层,小弟愚笨,这个还真不好做。
qingfeng_wu熊可能对我说的理解错了,我的并非固定按钮或控件,我是在DataList中的ItemTemplate里面的中增加一个层,这个层当鼠标移动到到该table中,显示层。由于ItemTemplate是个模板,数据绑定后会有许多由该模板生成的单元,当鼠标移动到不同的单元,会显示该单元的层,小弟愚笨,这个还真不好做。我知道你要这个效果,我上面不是说了吗:给你要显示的按钮div标签加上一定的规律,规律是自己加的,然后按照自己的需求去写算法。