可点击的网格视图行asp.net [英] clickable grid view row asp.net
本文介绍了可点击的网格视图行asp.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想要带有可点击行的asp.net gridview.
i want asp.net gridview with its rows clickable.
我想根据行索引单击该行时调用一个函数.
i want to call a function when that row is clicked based on row index.
我尝试使用RowDataBound事件,但是对我来说还是无效
i tried to use RowDataBound event but it did not worked or me
我使用了以下代码
protected void PeopleGridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes["onmouseover"] = "this.style.cursor='hand';this.style.textDecoration='underline';";
e.Row.Attributes["onmouseout"] = "this.style.textDecoration='none';";
e.Row.Attributes["onclick"] = ClientScript.GetPostBackClientHyperlink(this.PeopleGridView, "Select$" + e.Row.RowIndex);
}
}
我要去哪里错了?
我不想重定向到任何其他页面.我想在同一页面的文本框中填充值
i dont want to redirect to any other page. i want to fill the values in text box on the same page
推荐答案
您可以在javascript中创建一个函数,然后从行的鼠标事件中调用它.
You can make a function in javascript and call it from mouse event of row.
Javacript
<script language="javascript" type="text/javascript">
function setStyle(obj)
{
obj.style.cursor='hand';
obj.style.textDecoration='underline';
}
function resetStyle(obj)
{
this.style.textDecoration='none';
}
</script>
隐藏代码
protected void PeopleGridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes["onmouseover"] = "setStyle(this);";
e.Row.Attributes["onmouseout"] = "resetStyle(this);";
e.Row.Attributes["onclick"] = ClientScript.GetPostBackClientHyperlink(this.PeopleGridView, "Select$" + e.Row.RowIndex);
}
}
这篇关于可点击的网格视图行asp.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文