CallClinetScript 选中行调用前台事件
<script language="javascript" type="text/javascript">
// <!CDATA[
function btnSelect_onclick(id,name) {
alert("用户ID:"+id+" 用户名:"+name) ;
return false ;
}
// ]]>
</script>
//GridView控件的行数据绑定事件
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow) //如果是数据行
{
GridView grid = sender as GridView; //取当前操作的GridView
//取出GridView当前行的键值
string id = grid.DataKeys[e.Row.RowIndex].Value.ToString();
//取出GridView当前行指定列的值
string name = e.Row.Cells[2].Text;
//设置GridView当前行按钮的客户端事件
((LinkButton)(e.Row.Cells[grid.Columns.Count - 1].Controls[0])).Attributes.Add("onclick", "return btnSelect_onclick('" + id + "','" + name + "')");
}
}