completely stuck on fileupload in griidview

Discussion in 'ASP .Net' started by Stephanie, Jan 10, 2009.

  1. Stephanie

    Stephanie Guest

    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, Jan 10, 2009
    #1
    1. Advertising

  2. Stephanie

    Stephanie Guest

    Stephanie wrote:
    > 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.
     
    Stephanie, Jan 13, 2009
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeff S
    Replies:
    1
    Views:
    372
    Scott Allen
    Jan 20, 2004
  2. vMike
    Replies:
    0
    Views:
    317
    vMike
    Jan 23, 2004
  3. =?Utf-8?B?RGltaXRyaXMgUGFudGF6b3BvdWxvcw==?=

    I completely disagree

    =?Utf-8?B?RGltaXRyaXMgUGFudGF6b3BvdWxvcw==?=, Jul 2, 2004, in forum: ASP .Net
    Replies:
    11
    Views:
    638
    Kevin Spencer
    Jul 6, 2004
  4. Comfort
    Replies:
    1
    Views:
    476
    Enrique Santa Cruz
    Nov 5, 2004
  5. Bill Cunningham

    completely stuck

    Bill Cunningham, May 29, 2008, in forum: C Programming
    Replies:
    14
    Views:
    517
Loading...

Share This Page