光棒效果:
写在RowDataBound事件里面
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#6699ff'");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor");
}
删除操作写在RowDeleting事件
获取ID
int ID = Convert.ToInt32(Leave.DataKeys[e.RowIndex].Value.ToString());
记得在DataKeyNames属性里面写上要取的属性
编辑操作
进入编辑模式 Leave_RowEditing事件
Leave.EditIndex = e.NewEditIndex;
然后重新读取数据
退出编辑模式RowCancelingEdit事件
Leave.EditIndex = -1;
读取数据
修改数据 RowUpdating事件
int ID =Convert.ToInt32(Leave.DataKeys[e.RowIndex].Value.ToString());
string Title = ((TextBox)(Leave.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString();
string Content = ((TextBox)(Leave.Rows[e.RowIndex].Cells[2].Controls[0])).Text.ToString();
string User = ((TextBox)(Leave.Rows[e.RowIndex].Cells[3].Controls[0])).Text.ToString();
Leave.EditIndex = -1;
//重新加载数据
分页PageIndexChanging事件
Leave.PageIndex = e.NewPageIndex;
重新加载数据
写在RowDataBound事件里面
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#6699ff'");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor");
}
删除操作写在RowDeleting事件
获取ID
int ID = Convert.ToInt32(Leave.DataKeys[e.RowIndex].Value.ToString());
记得在DataKeyNames属性里面写上要取的属性
编辑操作
进入编辑模式 Leave_RowEditing事件
Leave.EditIndex = e.NewEditIndex;
然后重新读取数据
退出编辑模式RowCancelingEdit事件
Leave.EditIndex = -1;
读取数据
修改数据 RowUpdating事件
int ID =Convert.ToInt32(Leave.DataKeys[e.RowIndex].Value.ToString());
string Title = ((TextBox)(Leave.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString();
string Content = ((TextBox)(Leave.Rows[e.RowIndex].Cells[2].Controls[0])).Text.ToString();
string User = ((TextBox)(Leave.Rows[e.RowIndex].Cells[3].Controls[0])).Text.ToString();
Leave.EditIndex = -1;
//重新加载数据
分页PageIndexChanging事件
Leave.PageIndex = e.NewPageIndex;
重新加载数据