我希望能够在单击 gridview 行时调用一个函数。怎么做
这是我处理点击gridview行的地方
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
// somthing like
// e.Row.Attributes["onclick"] = go to Myfunction;
//OR
// e.Row.Attributes.Add("onclick", Myfunction);
}
}
这是我想调用的函数
protected void Myfunction(object sender, EventArgs e)
{
int id = 0;
foreach (GridViewRow myrow in GridView1.Rows)
{
RadioButton btn= (RadioButton)row.FindControl("RadioButton1");
if (btn.Checked)
{
id = Convert.ToInt32(GridView1.Rows[row.RowIndex].Cells[1].Text);
}
}