What I mean is that I don't want to put business logic about e.g. where an
object is saved in the presentation layer. If this is something that you
can't really acheive with the formview/objectdatasorce I have a work around
it's not very good but I have posted it. A cleaner solution is to bind the
the stream to byte array and use that in the business layer.
My slightly hacky work around is to tell pass the business object the name
of the formview and fileupload and it find it on the page. It works but I
don't like it....
<form id="form1" runat="server" enctype="multipart/form-data">
<div>
<asp:FormView ID="frmvwCustomer" runat="server"
DataSourceID="objdsCustomer" DefaultMode="Insert" AllowPaging="True">
<InsertItemTemplate>
Name<asp:TextBox ID="txtname" runat="server"></asp:TextBox><br />
Email<asp:TextBox ID="txtemail" Text="<%# Bind('strEmail') %>"
runat="server"></asp:TextBox><br />
CV<asp:FileUpload ID="CV" runat="server" /><br />
<asp:Button ID="Button1" runat="server" CommandName="Insert"
Text="Button" />
</InsertItemTemplate>
</asp:FormView>
</div>
<asp:ObjectDataSource ID="objdsCustomer" runat="server"
InsertMethod="createcustomer"
SelectMethod="getcustomer_list" TypeName="Customer">
<InsertParameters>
<asp:Parameter Name="strname" Type="String" />
<asp:Parameter Name="strEmail" Type="String" />
<asp:Parameter Name="formview" DefaultValue="frmvwCustomer" Type="String" />
<asp:Parameter Name="upload" DefaultValue="CV" Type="String" />
</InsertParameters>
</asp:ObjectDataSource>
</form>
Public Sub createcustomer(ByVal strname As String, ByVal strEmail As String,
ByVal formview As String, ByVal upload As String)
Dim page As Page = HttpContext.Current.CurrentHandler
Dim frmvw As FormView = CType(page.FindControl(formview), FormView)
Dim fileup As FileUpload = CType(frmvw.FindControl(upload), FileUpload)
Dim cv() As Byte = fileup.FileBytes
HttpContext.Current.Response.Write(cv)
HttpContext.Current.Response.ContentType = "application/pdf"
HttpContext.Current.Response.AddHeader("Content-Disposition",
"attachment;filename = test.pdf")
HttpContext.Current.Response.BinaryWrite(cv)
HttpContext.Current.Response.End()
End Sub
[quoted text, click to view] "Jon Paal [MSMD]" <Jon[ nospam ]Paal @ everywhere dot com> wrote in message
news:%23wOPSn8cHHA.984@TK2MSFTNGP04.phx.gbl...
>I may be missing your objective, but it seems that a formview, and
>associated upload control, would be dealt with through an event handler
>(code beside or in page) rather than a business object layer...
>
>
>