File upload within datagrid

Discussion in 'ASP.NET / ASP.NET Core' started by superwizbang, Feb 26, 2006.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Hello all.
    I am building a photo gallery page. In this page I have built a datagrid which has a template column. Within this column, I have the title of a <widget> and below it is an image of said <widget>. If the user chooses the "edit" option, the photo is hidden and an input box is displayed. Clicking the associated button opens the file dialog box we are all familiar with.
    In the update sub of the codebehind I need to capture the name of the file and then save the file to the server. How do I reference that control found in the datagrid so that I may do work with it? If it were a normal ASP.NET control such as a textbox, this would be an easy task. Just make a new textbox, set it equal to e.Item.cells(0).findcontrol(myControl) and there you go.
    There is more to this however. Can this be done in a datagrid? I really hope so. The normal code would look something like this:
    strFileName = File2.PostedFile.FileName
    If strFileName <> "" Then
    strImage = System.IO.Path.GetFileName(strFileName)
    If (Not File.Exists(strFolderName + "\" + strFileName)) Then
    File2.PostedFile.SaveAs(strFolderName + "\" + strImage)
    Else
    lblUpMain.Visible = True
    lblUpMain.Text = "File already exists! Change name before uploading."
    End If
    End If
    Obviously, "File2" is not recognized since there is no indexing associated from the start. So, how do I approach this?
    Thanks in advance!
    -Ken
     
  2. For those who might be interested,I spent quite a while looking for this, but the answer I was looking for is below. I don't think I asked the question quite right. I thought I could gain access to the control, but how would I use it. The answer is this:

    Dim strFile As HtmlInputFile

    With that reference I then had full access to all the properties of that control.

    -Ken
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page