关于GridView的增删改

a47305816 2009-01-20 09:15:06
我想在GridView填加增删改
查询已经完成了

请高手赐教
...全文
134 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
a47305816 2009-01-20
  • 打赏
  • 举报
回复
不知道改搜什么字
搜出来的都不是想要的
suners 2009-01-20
  • 打赏
  • 举报
回复
数据库操作了搜网上的友好多例子
a47305816 2009-01-20
  • 打赏
  • 举报
回复
要改哪个属性?
在数据库那改的?
还是在事件那改的
a47305816 2009-01-20
  • 打赏
  • 举报
回复
谁教下QQ233168121
或者发QQ我加下~
j45kp 2009-01-20
  • 打赏
  • 举报
回复
protected void profileGridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
profileGridView.PageIndex = e.NewPageIndex;
gvBind();
}
protected void profileGridView_RowEditing(object sender, GridViewEditEventArgs e)
{
profileGridView.EditIndex = e.NewEditIndex;
gvBind();
}
protected void profileGridView_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
profileGridView.EditIndex = -1;
gvBind();
}

protected void profileGridView_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
string destination = ((TextBox)profileGridView.Rows[e.RowIndex].Cells[0].Controls[0]).Text;
string ship = ((TextBox)profileGridView.Rows[e.RowIndex].Cells[1].Controls[0]).Text;
string myStr = 连接语句
string SqlStr = "update 语句
try
{
OleDbConnection conn = new OleDbConnection(myStr);

OleDbCommand cmd = new OleDbCommand();
cmd.Connection = conn;
cmd.CommandText = SqlStr;
cmd.CommandType = CommandType.Text;
cmd.CommandTimeout = 10;
if (conn.State == ConnectionState.Closed)
{
conn.Open();
}
int i = cmd.ExecuteNonQuery();
//if (conn.State == ConnectionState.Open)
conn.Close();
profileGridView.EditIndex = -1;
gvBind();
}
catch (Exception ex)
{
Response.Write("数据库错误,错误原因:" + ex.Message);
Response.End();
}

}
protected void profileGridView_RowDeleting(object sender, GridViewDeleteEventArgs e)
{

DeleteAdminInfo(itemId);
gvBind();
}
public void DeleteAdminInfo(string itemId)
{
string myStr = 链接字符
OleDbConnection conn = new OleDbConnection(myStr);

OleDbCommand cmd = new OleDbCommand();
cmd.Connection = conn;
cmd.CommandText = delete 语句

cmd.CommandType = CommandType.Text;
//添加参数
OleDbParameter id = new OleDbParameter(":profile_id", OleDbType.Char, 36);
id.Value = itemId;
cmd.Parameters.Add(id);
//执行过程
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
llsen 2009-01-20
  • 打赏
  • 举报
回复
winform
or
web
的?
gtiroy 2009-01-20
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 gtiroy 的回复:]
你看看 天弘穿 的视频就行了
[/Quote]
鼠标简单点两下就行了。
gtiroy 2009-01-20
  • 打赏
  • 举报
回复
你看看 天弘穿 的视频就行了
xiaoyanwei2000 2009-01-20
  • 打赏
  • 举报
回复
删除修改在gridview 的属性中就可以设置allowedit,allowdelete添加你就要操作数据元了
zjybushiren88888 2009-01-20
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 zgke 的回复:]
GridView 你修改 添加 删除 都在数据源里操作,..
[/Quote]

同意
zgke 2009-01-20
  • 打赏
  • 举报
回复
GridView 你修改 添加 删除 都在数据源里操作,..
a47305816 2009-01-20
  • 打赏
  • 举报
回复
我用的是Microsoft Visual Studio 2005
新手,发发代码

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧