在asp.net中选择行时,为gridview触发客户端事件 [英] fire client side event for gridview on selection of row in asp.net
本文介绍了在asp.net中选择行时,为gridview触发客户端事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
HI
任何人都可以告诉我如何在选择gridview行时解雇客户端事件而不使用其他控件,我的搜索都没有给我带来结果。
谢谢
HI
Can any one tell me how to fire client side event on selection of gridview row with out using other controls , none of my search brought me result.
Thank you
推荐答案
我不认为gridview控件有任何客户端会外活动。
...但是,当它呈现一个html表时,你可以创建并附上你自己的。
这是一个例子,它可以帮助你入门:
http://weblogs.asp.net/andrewrea/archive/2008/08/04/gridview-row-click-selection-via-clientside-code.aspx 一> [ ^ ]
...希望它有所帮助。
I don't think the gridview control has any client side events.
... but, as it renders an html table, you can create and attach your own.
Here is an example, which should get you started:
http://weblogs.asp.net/andrewrea/archive/2008/08/04/gridview-row-click-selection-via-clientside-code.aspx[^]
... hope it helps.
是的。尝试如下。使用RowDataBound
事件。
Yes ofcourse. Try like below. UseRowDataBound
Event.
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
//check the item being bound is actually a DataRow, if it is,
//wire up the required html events and attach the relevant JavaScripts
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes["onclick"] =
"javascript:gridRowOnclick(this);";
}
}
然后写 JavaScript
函数 gridRowOnclick
。
Then write JavaScript
function gridRowOnclick
.
function gridRowOnclick(element)
{
alert("GridView clicked");
}
这篇关于在asp.net中选择行时,为gridview触发客户端事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文