急急急急急急急急急急急急急GrieView行单击事件
思路就是点击时通过__doPostBack执行服务器事件。
前台代码
<asp:TemplateField> <ItemTemplate>
<asp:Button
ID= "btnShowDetail "
runat= "server "
Text= ' <%# Eval( "fName ") %> '
CssClass= "btnNoBorder "
OnClick= "btnShowDetail_Click ">
</asp:Button>
</ItemTemplate> </asp:TemplateField>
后台
protected void gvFriendList_RowDataBound(object sender, GridViewRowEventArgs e)
{ if (gvr.RowType == DataControlRowType.DataRow)
{
Button btn = (Button)gvr.FindControl( "btnShowDetail ");
gvr.Attributes.Add( "onclick ", "__doPostBack( ' " + btn.ClientID + " ', ' '); ");
}
}
}
这是FF中查看生成的代码
<tr onclick= "__doPostBack( 'gvFriendList_ctl03_btnShowDetail ', ' '); ">
<td>
<input id= "gvFriendList_ctl03_ckBox " type= "checkbox " name= "gvFriendList$ctl03$ckBox " />
&nbs