效果:可以选中GridView的一行,然后单击,GridView外面的一个修改按钮
让选中的哪一行变成,文本框的格式,然后,单击保存,可以修改到数据库里面。
本人菜鸟,那位大侠有例子,请发到[email protected]谢谢~~!!!
分也不多,请见谅~!!
让选中的哪一行变成,文本框的格式,然后,单击保存,可以修改到数据库里面。
本人菜鸟,那位大侠有例子,请发到[email protected]谢谢~~!!!
分也不多,请见谅~!!
解决方案 »
- windows seerver 2003+VS2008建的ASP.NET为啥在windows下打不开
- FlashPrinter转换错误
- 跨浏览器cookie如何实现
- cs文件定义的属性,为什么aspx文件无法使用?
- 导入数据到数据库时有客户查询怎么办??
- membership类好使吗??
- sql 组合语句查询问题
- 请问怎么会验证控件验证一个checkbox是否被选中
- 为何网页一刷新总是会提示“不重新发送信息则无法刷新该页”急,在线等!!!
- 在Visual Studio .NET里面有没有快速发布Web Application的方法?
- asp.net操作跳转页面控件
- asp.net 使用mysql数据库,报错:值对于无符号的字节太大或太小
<asp:TextBox id="txt" MaxLength="100" runat="server" Text='<%# Eval("NAME") %>' Width="86%">
</asp:TextBox>
</EditItemTemplate>
protected void gv_RowEditing(object sender, GridViewEditEventArgs e)
{
this.gv.EditIndex = e.NewEditIndex;
BindData();
} protected void gv_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
this.gv.EditIndex = e.RowIndex;
int id = int.Parse(this.gv.DataKeys[e.RowIndex].Value.ToString());
string str = ((TextBox)this.gvTarget.Rows[e.RowIndex].FindControl("txt")).Text.Trim();
this.gv.EditIndex = -1;
BindData();
}
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="edit" CausesValidation="false" OnClientClick="return confirm('确认要编辑吗?');">编辑</asp:LinkButton>
protected void GvCatalog_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
GvCatalog.EditIndex = -1;
BindGvCatalog();
} protected void GvCatalog_RowEditing(object sender, GridViewEditEventArgs e)
{
GvCatalog.EditIndex = e.NewEditIndex;
BindGvCatalog();
}protected void GvCatalog_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
if (CheckCatalog(((TextBox)(GvCatalog.Rows[e.RowIndex].Cells[1].Controls[0])).Text.Trim()))
{
if (((TextBox)(GvCatalog.Rows[e.RowIndex].Cells[1].Controls[0])).Text.Length <= 10)
{
SqlConnection con = new SqlConnection(DbConnection.ConnectionString);
con.Open();
string cmdstring = "UPDATE TabCatalog SET CatalogName='" + ((TextBox)(GvCatalog.Rows[e.RowIndex].Cells[1].Controls[0])).Text.Trim() + "' WHERE Id='" + GvCatalog.Rows[e.RowIndex].Cells[0].Text + "' ";
SqlCommand cmd = new SqlCommand(cmdstring, con);
int result = cmd.ExecuteNonQuery();
if (result > 0)
{
GvCatalog.EditIndex = -1;
BindGvCatalog(); } }
else
{
Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>window.alert('不要大于10个字!')</script>");
} }
else
{
Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>window.alert('该分类已经存在!')</script>");
}
}
{
if (((TextBox)(GvCatalog.Rows[e.RowIndex].Cells[1].Controls[0])).Text.Length <= 10)
{
这个可以不要 是判断输入的内容是否正确的