Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. insert data from 10 textboxes

insert data from 10 textboxes

Scheduled Pinned Locked Moved ASP.NET
questiondatabase
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    andyk1967
    wrote on last edited by
    #1

    I have a simple question wich probably can be easily answered but I'm clueless. On a webform people can invite friends (lets say 10). So I have 10 times dropdown: Mr. / Mrs., 10 times: Tetxtbox; firstname and 10 times: Textbox emailadres. I want to insert these in tabel tblfriends. Before I insert I would like to do some validation to see if the friend allready exists in the database, sent an email to the person etc. But that is not the point really. Would I end up writing ten insert queries with lstmrmrs1, txtfirstname1, txtemal1 then lstmrmrs2, txtfirstname2, txtemal2, etc. up to 10 ? I have googled quite a bit but can't find a hint.

    G 1 Reply Last reply
    0
    • A andyk1967

      I have a simple question wich probably can be easily answered but I'm clueless. On a webform people can invite friends (lets say 10). So I have 10 times dropdown: Mr. / Mrs., 10 times: Tetxtbox; firstname and 10 times: Textbox emailadres. I want to insert these in tabel tblfriends. Before I insert I would like to do some validation to see if the friend allready exists in the database, sent an email to the person etc. But that is not the point really. Would I end up writing ten insert queries with lstmrmrs1, txtfirstname1, txtemal1 then lstmrmrs2, txtfirstname2, txtemal2, etc. up to 10 ? I have googled quite a bit but can't find a hint.

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      You should look into the concept of looping. A loop will enable you to repeatedly execute some of your code, so that you don't have to write the same code over and over again. --- b { font-weight: normal; }

      A 1 Reply Last reply
      0
      • G Guffa

        You should look into the concept of looping. A loop will enable you to repeatedly execute some of your code, so that you don't have to write the same code over and over again. --- b { font-weight: normal; }

        A Offline
        A Offline
        andyk1967
        wrote on last edited by
        #3

        That is a little bit too vague... I think it should be solved with the creation of a datatable somehow but dunno more than that. With only a loop I still have the problem that the textboxes have a name: textbox1, textbox2, etc.

        G 1 Reply Last reply
        0
        • A andyk1967

          That is a little bit too vague... I think it should be solved with the creation of a datatable somehow but dunno more than that. With only a loop I still have the problem that the textboxes have a name: textbox1, textbox2, etc.

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          Yes, I was a bit vague, but your question was quite vauge. You don't need a datetable to update several records, but you can use that if you want. I would just do the updates one by one. That's the way the datatable does them in the end anyway. The textbox names is not a problem. You can get the textboxes by name: Page.FindControl("textbox" + i) Or you can put references in an array: TextBox[] boxes = new TextBox[] { textbox1, textbox2 ... }; --- b { font-weight: normal; } -- modified at 15:56 Sunday 8th January, 2006

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups