62,046
社区成员
发帖
与我相关
我的任务
分享
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
string ID = GridView1.DataKeys[e.RowIndex].Value.ToString();
string UserName = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString().Trim();
string UserRealName = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[3].Controls[0])).Text.ToString().Trim();
string RoleID = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[4].Controls[0])).Text.ToString().Trim();
string sqlStr = "update tb_User set UserName='" + UserName + "',UserPwd='" + UserPwd + "',UserRealName='" + UserRealName + "',RoleID='"+ RoleID+"' where UserID=" + ID + "";
DbHelperSQL.DbHelperSQL.ExecuteSql(sqlStr);
GridView1.EditIndex = -1;
}
string UserPwd = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[2].Controls[0])).Text.ToString().Trim();
UserPwd = MD5(UserPwd, 32);
string UserPwd = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[2].Controls[0])).Text.ToString().Trim();
UserPwd=System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(UserPwd, "MD5").ToLower();
//MD5加密
public static string MD5(string str, int code)
{
if (code == 16)//16位
{
return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5").ToLower().Substring(8, 16);
}
else//32位
{
return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5").ToLower();
}
}
/*
-- "insert into xxx(xxx,xxx) values('" + TextBox1.Text.ToString()
-- + "','" + MD5(TextBox2.Text.ToString(), 32) + "')"
*/