楼主发表于:2009-10-08 13:31:25当单击按钮时,将弹出一个上传图片的对话框。然后选择一副图片,单击确定按钮,图片将从原来的位置复制到picture文件夹下。但是在运行到UserManager.WorkerRow currentrow =currentRowView.Row as UserManager.WorkerRow时就会报错。UserManager是我定义的一个类。提示错误为“UserManager中没有WorkerRow的定义 。”怎么改啊?其中Wphoto 为Worker表中的一个字段。 
private void button10_Click(object sender, EventArgs e) 
        { 
            open = new OpenFileDialog(); 
            open.Filter="bmp|*.bmp|ipg|*.jpg|gif|*.gif|ico|*.ico|所有文件|*.*"; 
            if (open.ShowDialog() == DialogResult.OK) 
            { 
                if (open.FileName != null) 
                { 
                    photobox.Image = Image.FromFile(open.FileName); 
                    //获取图片路径 
                    string path = Path.GetDirectoryName(Application.ExecutablePath) + "\\picture\\" + Path.GetFileName(open.FileName); 
                    //将图片复制到picture文件夹中 
                    System.IO.File.Copy(open.FileName, path, true); 
                    DataRowView currentRowView = bindingSource1.Current as DataRowView; 
                    UserManager.WorkerRow currentrow = 
                        currentRowView.Row as UserManager.WorkerRow; 
                    currentrow.Wphoto = path;//指定Wphoto字段的值为图片路径。 
                } 
            }         }