protected override void Render(HtmlTextWriter writer)
{
foreach (GridViewRow Row in GridView1.Rows)
{
if (Row.RowType == DataControlRowType.DataRow)
{
//双击进入编辑模式
Row.Attributes["ondblclick"] = ClientScript.GetPostBackEventReference(GridView1, "Edit$" + Row.RowIndex.ToString(), true);
Row.Attributes["style"] = "cursor:pointer";
Row.Attributes["title"] = "双击进入编辑";
if ((Row.RowState & DataControlRowState.Edit) != 0)
{
Row.Attributes.Remove("ondblclick");
Row.Attributes.Remove("style");
Row.Attributes["title"] = "编辑行";
//for (Int32 i = 1; i < GridView1.Columns.Count; i++)
//{
// ((TextBox)Row.Cells[i].Controls[1]).Attributes.Add("onmouseover", "this.select()");
//}
//双击更新
Row.Attributes["ondblclick"] = ClientScript.GetPostBackEventReference(GridView1, "Update$" + Row.RowIndex.ToString(), true);
}
//
for (int i = 1; i < Row.Cells.Count; i++)
{
Page.ClientScript.RegisterForEventValidation(Row.UniqueID + "$ctl00", i.ToString());
}
}
}
base.Render(writer);
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
gvBind();
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
//.....
}