ASP.Net列表视图可点击行,突出选中的项目 [英] ASP.Net listview with clickable rows which highlights selected item

查看:221
本文介绍了ASP.Net列表视图可点击行,突出选中的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的ASP.net列表视图中的每一行包含几个组件的< D​​IV> ,我的问题有两个部分:

Every row of my ASP.net list view contains several components in a <div>, my question has two parts:


  1. 我怎样才能使该行可点击(尽量使用的SelectedIndexChanged 的事件)?我想根据点击什么行中的另一个用户控件加载某些数据。

  1. How can I make this row clickable (to make use of SelectedIndexChanged event)? I want to load some data in another user control based on what row is clicked.

我怎样才能使用(比如淡蓝色)箱周围或在它显示选中的行?

How can I show the selected row using (say a light blue) box around or over it?

感谢

更新

<script src="Scripts/jquery-1.10.1.min.js" type="text/javascript"></script>

 <link href="StyleSheet.css" rel="stylesheet" type="text/css" />

 <div class="clickable" url="http://www.google.com">
    Google
</div>

<div class="clickable" url="http://www.bing.com">
    Bing
</div>

<script type="text/javascript">
   $("div.clickable").mouseover(function () {
 //        $(this).css("outline-style", "solid");
 //        $(this).css("outline-color", "Navy");
 //        $(this).css("outline-width", "thin");
    $("#div.clickable").each(function () { $(this).removeClass("Selected") });
    $(this).addClass("Selected");
 });
 </script>

<script type="text/javascript">
    $("div.clickable").click(
    function () {
        window.location = $(this).attr("url");
    });
</script>

和风格会

.clickable
{
  cursor:pointer;
  cursor: hand;
}

.Selected
{
  outline-style:solid;
  outline-color:Navy;
  outline-width:thin;
}

然而,当鼠标越过其他项目它不工作。它不会清除previous项目的轮廓。

Yet it is not working when mouse goes over the other item. it does not clear the outline of the previous item.

推荐答案

您需要连接到ListView中的行绑定,并添加你想要点击时具有的信息。通过该功能,您可以将属性添加到您阅读回按一下按钮,例如...

You need to hook into the listview row bind and add the information you want to have when clicked. Using this, you can add an attribute to the button that you read back on click, for example...

有关的亮点,你可以在你的客户端使用这个jQuery:(<一href=\"http://stackoverflow.com/questions/11052761/asp-net-listview-highlight-row-on-click?rq=1\">asp.net在点击列表视图亮点行)

For the highlight you could use this JQuery in your client-side: (asp.net listview highlight row on click)

   $("#myTable tr").click( function () 
{
   $("#myTable tr").each(function () { $(this).removeClass("selected")}); 
   $(this).addClass("selected"); 
});​

这篇关于ASP.Net列表视图可点击行,突出选中的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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