当前位置: 代码迷 >> ASP.NET >> 怎么实现鼠标单击 选中 GridView 中的一行?
  详细解决方案

怎么实现鼠标单击 选中 GridView 中的一行?

热度:8169   发布时间:2013-02-25 00:00:00.0
如何实现鼠标单击 选中 GridView 中的一行?急!
如何实现鼠标单击   选中   GridView   中的一行?并不是简单地改变行的颜色,而是“真正”的选中!

注意,并非是在GridView中   添加   【选中】列,而是通过鼠标单击实现像   在GridView中添加   【选中】列的效果。

谢谢。

------解决方案--------------------------------------------------------
try:放一个hidden,一个button,display = "none ";在rowbound事件中. e.Row.Attribute.Add( "onclick ", "SetIndex( "+e.Row.ItemIndex+ ") ");脚本function SetIndex (i){ document.getElementById( "hidIndex ").value = i; document.getElementById( "btnSetIndex ").click();}后台事件btnSetIndex_Click{ this.GridView1.SelectedIndex = ConvertToIn32(this.hidIndex.value);}
------解决方案--------------------------------------------------------
学习
------解决方案--------------------------------------------------------
ls的ls 好搞笑。哈哈``
------解决方案--------------------------------------------------------
#region//行绑定事件
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
//鼠标略过行改变行颜色
e.Row.Attributes.Add( "onclick ", "c=style.backgroundColor;style.backgroundColor= 'skyblue '; ");

}
#endregion
------解决方案--------------------------------------------------------
学习暮白兄!
其实原理差不多.你点击选择然后后台调用gridview里面的选择按钮事件!!执行选择里面的程序就OK了!!
------解决方案--------------------------------------------------------
#region//行绑定事件
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
//鼠标点击行改变行颜色
e.Row.Attributes.Add( "onclick ", "c=style.backgroundColor;style.backgroundColor= 'skyblue '; ");

}
#endregion
------解决方案--------------------------------------------------------
确实挺搞笑得~
我一般都是添加一个隐藏列再去捕捉它的事件~
------解决方案--------------------------------------------------------
和改变行颜色的原理一样 !你变成取值不就是 ?
------解决方案--------------------------------------------------------
mark一下晚上贴,不过我是行上加用checkbox的,你合适吗
------解决方案--------------------------------------------------------
up
------解决方案--------------------------------------------------------
mark~~
------解决方案--------------------------------------------------------
#region//行绑定事件
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
//鼠标略过行改变行颜色
if(e.Row.RowType==DataControlRowType.DataRow)
{
e.Row.Attributes.Add( "onclick ", "c=style.backgroundColor;style.backgroundColor= 'skyblue '; ");
}
}
#endregion


这个代码不行吗?我试过了才给你的啊
  相关解决方案