protected void GridView1_RowEditing1(object sender, GridViewEditEventArgs e)
{
this.GridView1.EditIndex = e.NewEditIndex;//进入编辑模式
this.GridView1.DataBind();
}
在你新编辑的列里面添加一个Linbutton组件,然后设置成模板
设置后的代码如下,自行参考
PS:将你的GridView列都转换成模板,然后平时数据就以Label显示,编辑的时候就用TextBox显示,这样就方便取值了
举个例子:编辑状态获取一个你选定行的账号和密码
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
string id = (GridView1.Rows[e.RowIndex].FindControl("TextBox2") as TextBox).Text;
string password =(GridView1.Rows[e.RowIndex].FindControl("TextBox3") as TextBox).Text;
}
那就在同一列,绑定两个按钮就是了。
一点击,更新,删除,都出来了。
private void Export(string FileType, string FileName)
{
gvStudents.Columns[3].Visible = false;//***********
gvStudents.Columns[4].Visible = false;//***********
Response.Charset = "GB2312";
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8).ToString());
Response.ContentType = FileType;
this.EnableViewState = false;
StringWriter tw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(tw);
gvStudents.RenderControl(hw);
Response.Write(tw.ToString());
Response.End();
}
只需要在导出时把删除编辑列隐藏掉就可以了。
另外,虚机团上产品团购,超级便宜