我有一个ASP.NET的GridView它使用模型绑定时发送参数BLL:使用Web窗体模型绑定和文件上传在GridView
<asp:GridView runat="server" ID="teamMembersGrid"
...
ItemType="Models.TeamMember"
OnCallingDataMethods="teamMembersGrid_CallingDataMethods">
我也有一个BLL定义为UpdateTeamMember,InsertTeamMember方法,等等。
网格的其中一列显示图像。在编辑模式下,我需要使用FileUpload控件上传此列的新图像。我想将此控件作为参数传递给BLL方法UpdateTeamMember。问题是:如何?
我在页面外添加了一个ID为“FileUpload”的FileUpload控件。它有style =“display:none”(我试图去除这种风格,但它没有帮助)。然后,在RowUpdating,我设定此控制的值:
protected void teamMembersGrid_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
FileUpload = teamMembersGrid.Rows[e.RowIndex].FindControl("FileUpload") as FileUpload;
}
在该方法中,FileUpload控件正确检索并且它具有所需的信息。
而在BLL,我有这样的:
public void UpdateTeamMember(int teamMemberID, ModelMethodContext context, [Control("FileUpload")] FileUpload fileUpload)
{
...
}
在BLL的这种方法,文件上传参数不为空,但并没有任何文件上传。
任何帮助,非常感谢。谢谢!