https://bbs.csdn.net/topics/350100104
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "edit_admin")
{
GridView1.EditIndex = Convert.ToInt32(e.CommandArgument);
db_common();
}
else
{
if (e.CommandName == "Page")
{
}
else
{
SqlCommand cmd = new SqlCommand();
string sql = "";
fun fun = new fun();
fun.Page = this.Page;
DataTable dt = new DataTable();
Button x = e.CommandSource as Button;
TextBox textBox1 = x.FindControl("TextBox1") as TextBox;
TextBox textBox2 = x.FindControl("TextBox2") as TextBox;
TextBox textBox3 = x.FindControl("TextBox3") as TextBox;
Label label = x.FindControl("Label3") as Label;
sql = "UPDATE AFM_USER SET Name = @Name,MyPhone = @MyPhone,Title = @Title,UpdateDate=@UpdateDate,UpdateUserId=@UpdateUserId WHERE Account=@Account ";
cmd.CommandText = sql;
cmd.Parameters.Clear();
cmd.Parameters.AddWithValue("@Account", label.Text);
cmd.Parameters.AddWithValue("@Name", textBox1.Text);
cmd.Parameters.AddWithValue("@MyPhone", textBox3.Text);
cmd.Parameters.AddWithValue("@Title", textBox2.Text);
cmd.Parameters.AddWithValue("@UpdateDate", DateTime.Now);
cmd.Parameters.AddWithValue("@UpdateUserId", Session["Account"].ToString());
int a = fun.CmdExec(cmd);
if (a == 0)
{
fun.message("更新失敗!!!");
}
else
{
fun.message("已成功更新了" + a + "筆資料");
}
GridView1.EditIndex = -1;
db_common();
}
}
}
沒有留言:
張貼留言