Results 1 to 3 of 3

Thread: Dynamically create <tr> and input file fields

  1. #1

    Thread Starter
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861

    Dynamically create <tr> and input file fields

    I have an ASP.NET application that allows a user to select if they want to upload an attachment.

    If they check yes, then a dropdown list appears that allows them to select a number 1-5 to specify the number of files they will be uploading...

    What I need to do it determine the number in the dropdown list, then dynamically create that many rows immediately below the dropdown list and add input type controls within a column of the newly created rows.

    any ideas on the best way to do this?

    Would a Repeater control be a good idea for this???
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    If you use the ASP.NET table then you can just add the rows in code on the selection type event of the combo.

    Dim cntMax As Integer=Integer.Parase(combo1.SelectedText)
    For cnt As Integer=1 to cntMax
    Dim newRow As New TableRow()
    Dim lbl As New Label()
    lbl.Text="File #1"
    newRow.Controls.Add(lbl)
    tblUpload.Rows.Add(newRow)
    Next

    You could also just use an old time asp style script to handle it but asp.net is better.

    Here I changed it a little bit, you'll probably have to do a little more to wire up the file upload input thingy, but...
    VB Code:
    1. Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
    2.         Table1.Rows.Clear()
    3.         Dim cntmax As Integer = Integer.Parse(DropDownList1.SelectedItem.Text)
    4.         For cnt As Integer = 1 To cntmax
    5.             Dim newRow As New TableRow
    6.             Dim lbl As New Label
    7.             lbl.Text = "File #" & cnt & ": <INPUT type=""file"">"
    8.             Dim newCell As New TableCell
    9.             newCell.Controls.Add(lbl)
    10.             newRow.Controls.Add(newCell)
    11.             Table1.Rows.Add(newRow)
    12.         Next
    13.     End Sub
    Last edited by Edneeis; Dec 2nd, 2003 at 06:55 PM.

  3. #3

    Thread Starter
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    Thanks for the help, but I think I am going to do it another way...instead of generating multiple file controls...I will just display 1 control and allow them to upload multiple attachments and keep track of how many they upload by adding and displaying them in a listbox.
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width