关于GridView的增删改
我想在GridView填加增删改查询已经完成了
请高手赐教 --------------------编程问答-------------------- 我用的是Microsoft Visual Studio 2005
新手,发发代码 --------------------编程问答-------------------- GridView 你修改 添加 删除 都在数据源里操作,.. --------------------编程问答--------------------
同意 --------------------编程问答-------------------- 删除修改在gridview 的属性中就可以设置allowedit,allowdelete添加你就要操作数据元了 --------------------编程问答-------------------- 你看看 天弘穿 的视频就行了 --------------------编程问答--------------------
鼠标简单点两下就行了。 --------------------编程问答-------------------- winform
or
web
的?
--------------------编程问答-------------------- 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();
} --------------------编程问答-------------------- 谁教下QQ233168121
或者发QQ我加下~ --------------------编程问答-------------------- 要改哪个属性?
在数据库那改的?
还是在事件那改的 --------------------编程问答-------------------- 数据库操作了搜网上的友好多例子 --------------------编程问答-------------------- 不知道改搜什么字
搜出来的都不是想要的
补充:.NET技术 , C#