gridview鼠标双击事件(跳转至新页面并传值)单击获取值
2011-12-24 09:46
344 查看
gridview添加RowDataBound事件,并设置DataKeyName为绑定数据的主键
protected void gridview1_RowDataBound(object sender, GridViewRowEventArgs e)
{
//判断选择的是否是数据行
if (e.Row.RowType == DataControlRowType.DataRow)
{
int SId = Convert.ToInt32(this.gridview1.DataKeys[e.Row.RowIndex].Value);//获取DateKeyName的值
//鼠标在某行,变色
e.Row.Attributes.Add("onmouseover", "c=style.backgroundColor;style.backgroundColor='yellow'");
e.Row.Attributes.Add("onmouseout", "style.backgroundColor=c");
//添加双击事件(跳转至新页面)
e.Row.Attributes.Add("ondblclick", "window.open(a.aspx?SId=" + SId + "');");
//添加单击事件
e.Row.Attributes["onclick"] = ClientScript.GetPostBackEventReference(gridview1,"Select$"+e.Row.RowIndex.ToString());
}
双击后a页面接收sid
int sid = Convert.ToInt32(Request.QueryString["SId"]);
单击后获取单击行的DataKey
int value = Convert.ToInt32(this.gridview1.DataKeys[gridview1.SelectedIndex].Value);
protected void gridview1_RowDataBound(object sender, GridViewRowEventArgs e)
{
//判断选择的是否是数据行
if (e.Row.RowType == DataControlRowType.DataRow)
{
int SId = Convert.ToInt32(this.gridview1.DataKeys[e.Row.RowIndex].Value);//获取DateKeyName的值
//鼠标在某行,变色
e.Row.Attributes.Add("onmouseover", "c=style.backgroundColor;style.backgroundColor='yellow'");
e.Row.Attributes.Add("onmouseout", "style.backgroundColor=c");
//添加双击事件(跳转至新页面)
e.Row.Attributes.Add("ondblclick", "window.open(a.aspx?SId=" + SId + "');");
//添加单击事件
e.Row.Attributes["onclick"] = ClientScript.GetPostBackEventReference(gridview1,"Select$"+e.Row.RowIndex.ToString());
}
双击后a页面接收sid
int sid = Convert.ToInt32(Request.QueryString["SId"]);
单击后获取单击行的DataKey
int value = Convert.ToInt32(this.gridview1.DataKeys[gridview1.SelectedIndex].Value);
相关文章推荐
- GridView 单击选择行,双击打开详细页面,鼠标移到某行上变色
- gridview 单击行事件,并跳转页面带本行的ID
- 扩展GridView(六)——数据行响应鼠标的单击和双击事件
- GridView 单击选择行,双击打开详细页面,鼠标移到某行上变色
- GridView控件(六)—数据行响应鼠标的单击和双击事件
- 后台添加gridview事件(鼠标事件,单击双击事件)个人总结
- GridView 单击选择行,双击打开详细页面,鼠标移到某行上变色
- ASP.NET DEMO 15: 同时支持行单击和双击事件的 GridView/DataGrid
- 发现:Click事件也能获取鼠标单击的坐标
- gridview 双击单击事件
- 如何在页面上获取鼠标事件。
- Asp.net 2.0 GridView的几个事件(如实现: 行的双击/单击/捕捉键盘按键/鼠标悬浮/移出效果)(示例代码下载)
- js获取页面中的鼠标滚轮事件
- js鼠标单击和双击事件冲突问题的解决方法
- 完成功能是DataGrid的页面选中事件、鼠标事件、双击事件改变TR的色彩
- Asp.net 2.0 GridView的几个事件(如实现: 行的双击/单击/捕捉键盘按键/鼠标悬浮/移出效果)(示例代码下载)
- 新增Activity、页面传值跳转和点击按钮触发事件『Android系列九』
- ASPX页面如何获取ASPxGridView的FocusedRowChanged事件?
- 扩展GridView控件(6) - 响应行的单击事件和双击事件
- 扩展GridView控件(6) - 响应行的单击事件和双击事件