if(action=="updata")
{
int id=Convert.ToInt32(Request["Id"]); //取得要修改的Id
var newRow = new T_UserTableAdapter().GetDataById(id).Single(); //获取单条等于这个Id的数据到DataSet中
newRow.Tiele=TextBox1.Text;
newRow.Paiming=Convert.ToInt32(TextBox2.Text);
new T_UserTableAdapter().Updata(newRow);
}
Response.Redirect("http://www.baidu.com");
上传文件:虽然是后台,但是为了别人得到密码后恶意上传,所以还是要进行文件类型检验。
string ext =Path.GetExtension(fileuploadpic.FileName).ToLower();
string[] images={".jpg","png","gif","bmp","jpeg"};
foreach(string str in images)
{
if(images[i]==ext)
{
//恭喜配对成功!给予上传!
}
else
{
return;
}
}//这里是自己想的验证方法,在后缀名较多的时候应该可用。
if(ext!="jpg" && ext!="jpeg"&& ext!="png" &&ext!="gif")//检验是否图片;
{
ClientScript.RegisterStartupScript(GetType(),"警告","alert('文件类型错误!')",true);//返回客户端脚本很好用
return;
}
FileUpLoad fileuploadpic=(FileUpLoad) FormView1.FindContorl("fileuploadpic");
if(fileuploadpic.HasFile)//检验是否包含文件
{
fileuploadpic.SaveAs("~/ckfinder/userfiles/images/"+fileuploadpic.FileName);//这里需要解决重名的问题
}