我想获取单击的列的名称和单击的行的值。
我找到了很好的例子,但我无法获得我想要的数据。
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes["onClick"] = "location.href='view.aspx?id_lekarza=" + DataBinder.Eval(e.Row.DataItem, "Id_lekarza") + " &klikniete=" + "sss" + " '";
}
}
e.Row.RowIndex 一直为 0?
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onclick", "javascript:alert('" + e.Row.RowIndex + "');");
e.Row.Style.Add("cursor", "pointer");
}
}