completely stuck on fileupload in griidview

  • Thread starter Thread starter Stephanie
  • Start date Start date
S

Stephanie

I have a detailsview control. It is bound to an objectdatasource. I want to
have a fileupload control in the detailsview. So I added

<asp:TemplateField HeaderText="Photo"

SortExpression="pictureReference">



<EditItemTemplate>

<asp:FileUpload ID="pictureUpload" runat="server" />

</EditItemTemplate>

<InsertItemTemplate>

<asp:FileUpload ID="pictureUpload" runat="server" />

</InsertItemTemplate>

<ItemTemplate>



Dont know what I want to put here yet.



</ItemTemplate>

</asp:TemplateField>



Then I thought I would do something in the ItemUpdating event to save the
file (trivial) then have the field in the database reference the file name.



protected void ItemUpdating(object sender, DetailsViewUpdateEventArgs e)

{

// do something here to 1. upload the file and 2. set the pictureReference
field to the path

string appPath = HttpContext.Current.Request.ApplicationPath;

string physicalPath = HttpContext.Current.Request.MapPath(appPath);

physicalPath = physicalPath + "\\images\\";



//pictureUpload.PostedFile.SaveAs(physicalPath +
pictureUplad.PostedFile.FileName);


}



pictureUpload does not exist in this context. But some of my drop down list
template fields do.



I am flailing around like a clueless person. Anyone have a nudge to give me
on what event and what to do when I get tehre?



Thanks!
 
Stephanie said:
I have a detailsview control. It is bound to an objectdatasource. I
want to have a fileupload control in the detailsview. So I added

Snip a bunch of stuff that is not going to be the way I am going to do this.
I have been thinking of this all wrong. I am not going to do this directly
within the detailsview. I am going to do a separate ... page or something to
edit and replace if needs be.

I don't necessarily even want an upload control unless they want to change
the uploaded file for that record...

So anyway sorry for wasting your reading time.
 
Back
Top