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. javascripting with web controls

javascripting with web controls

Scheduled Pinned Locked Moved ASP.NET
javascripthtmlquestion
23 Posts 4 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.
  • C Chetan Ranpariya

    Hi, If you are creating seperate row for each of the item in the listbox then you have to loop through all the items and create intsert query in the loop and execute it.

    Thanks and Regards, Chetan Ranpariya

    B Offline
    B Offline
    bernie_011
    wrote on last edited by
    #13

    it works fine if i use dropdownlist, but in dropdownlist you will insert the data in the database individually right?. I want to use listbox for me to insert all the data in a single click of the button. God Bless you! Bernie Leynes

    C 1 Reply Last reply
    0
    • B bernie_011

      it works fine if i use dropdownlist, but in dropdownlist you will insert the data in the database individually right?. I want to use listbox for me to insert all the data in a single click of the button. God Bless you! Bernie Leynes

      C Offline
      C Offline
      Chetan Ranpariya
      wrote on last edited by
      #14

      HI, I am not getting you exact requirement. Can you pelase elaborate by giving an example? Thanks and Regards, Chetan Ranpariya

      B 1 Reply Last reply
      0
      • C Chetan Ranpariya

        HI, I am not getting you exact requirement. Can you pelase elaborate by giving an example? Thanks and Regards, Chetan Ranpariya

        B Offline
        B Offline
        bernie_011
        wrote on last edited by
        #15

        ok. heres my example I have 2 dropdown and a listbox and a table in my database drpcategory drpNames listbox1 table1- the columns are Category,Name I have items in drpcategory. the items are: Agent, Trainees In my drpNames the items are : Bernie, Ray, Kirby listbox1.items= drpNames.selecteditem.text If my listbox1 contains all the names from drpNames and i select "Agent" from drpCategory then i click insert button all the 3 names on my listbox will be inserted but different row. The result will be Category Name Agent Bernie Agent Ray Agent Kirby My problem is even if i have multiple items in my listbox then after i click insert int only insert 1 row in my table which is the first row only Bernie Leynes

        C 1 Reply Last reply
        0
        • B bernie_011

          ok. heres my example I have 2 dropdown and a listbox and a table in my database drpcategory drpNames listbox1 table1- the columns are Category,Name I have items in drpcategory. the items are: Agent, Trainees In my drpNames the items are : Bernie, Ray, Kirby listbox1.items= drpNames.selecteditem.text If my listbox1 contains all the names from drpNames and i select "Agent" from drpCategory then i click insert button all the 3 names on my listbox will be inserted but different row. The result will be Category Name Agent Bernie Agent Ray Agent Kirby My problem is even if i have multiple items in my listbox then after i click insert int only insert 1 row in my table which is the first row only Bernie Leynes

          C Offline
          C Offline
          Chetan Ranpariya
          wrote on last edited by
          #16

          hi, See in this case the solution is what I have told you before. U have to loop through all the items in the listbox and create INSERT query for each of the item and execute it. Can u send the code you have written?

          Thanks and Regards, Chetan Ranpariya

          B 1 Reply Last reply
          0
          • C Chetan Ranpariya

            hi, See in this case the solution is what I have told you before. U have to loop through all the items in the listbox and create INSERT query for each of the item and execute it. Can u send the code you have written?

            Thanks and Regards, Chetan Ranpariya

            B Offline
            B Offline
            bernie_011
            wrote on last edited by
            #17

            listbox1.items = drpNames.selecteditem.text this is how i get the items from dropdown and display in listbox. How can i Loop all the items from listbox? If i do looping it will insert all the items from listbox in my table in the database? Bernie Leynes

            C 1 Reply Last reply
            0
            • B bernie_011

              listbox1.items = drpNames.selecteditem.text this is how i get the items from dropdown and display in listbox. How can i Loop all the items from listbox? If i do looping it will insert all the items from listbox in my table in the database? Bernie Leynes

              C Offline
              C Offline
              Chetan Ranpariya
              wrote on last edited by
              #18

              Hi, The onel line of code u have given will not execute coz it will give compile time error. yes i u loop through all items in the listbox it will all the items from the listbox in the table in database. how do u try to insert data in the table in you database? Please paste your code here. Thanks and Regards, Chetan Ranpariya

              B 2 Replies Last reply
              0
              • C Chetan Ranpariya

                Hi, The onel line of code u have given will not execute coz it will give compile time error. yes i u loop through all items in the listbox it will all the items from the listbox in the table in database. how do u try to insert data in the table in you database? Please paste your code here. Thanks and Regards, Chetan Ranpariya

                B Offline
                B Offline
                bernie_011
                wrote on last edited by
                #19

                Heres my code.. INSERT INTO table1(category,Name)VALUES(@category,@name) category bind to drpcategory name bind to listbox1 You are blessed men. Thanks Bernie Leynes

                1 Reply Last reply
                0
                • C Chetan Ranpariya

                  Hi, The onel line of code u have given will not execute coz it will give compile time error. yes i u loop through all items in the listbox it will all the items from the listbox in the table in database. how do u try to insert data in the table in you database? Please paste your code here. Thanks and Regards, Chetan Ranpariya

                  B Offline
                  B Offline
                  bernie_011
                  wrote on last edited by
                  #20

                  I know you know how to do that man. Please help me.. Thanks and God Bless Bernie

                  C 1 Reply Last reply
                  0
                  • B bernie_011

                    I know you know how to do that man. Please help me.. Thanks and God Bless Bernie

                    C Offline
                    C Offline
                    Chetan Ranpariya
                    wrote on last edited by
                    #21

                    HI, I have asked you to paste your whole code here. but I dont think you want to do that. You are just pasting one or two lines and want me to do everything for you. Things doesnt happen like that. If you want to insert values from the listbox the commong logic is that you take items from the listbox one by one and create insert query for each of the item and execute the query. foreach(ListItem LI in lstbox.Items) { string strquery = "Insert Into table Values ('" + ddl.SelectedValue + "', '" + LI.Value + "')"; cmd.executenonquery(strquery); } THis is the commong logic. You implement this as per your requirement. If any further assistance is needed then do reply with the whole code u have written to insert the data in the table. Thanks and Regards, Chetan Ranpariya

                    B 2 Replies Last reply
                    0
                    • C Chetan Ranpariya

                      HI, I have asked you to paste your whole code here. but I dont think you want to do that. You are just pasting one or two lines and want me to do everything for you. Things doesnt happen like that. If you want to insert values from the listbox the commong logic is that you take items from the listbox one by one and create insert query for each of the item and execute the query. foreach(ListItem LI in lstbox.Items) { string strquery = "Insert Into table Values ('" + ddl.SelectedValue + "', '" + LI.Value + "')"; cmd.executenonquery(strquery); } THis is the commong logic. You implement this as per your requirement. If any further assistance is needed then do reply with the whole code u have written to insert the data in the table. Thanks and Regards, Chetan Ranpariya

                      B Offline
                      B Offline
                      bernie_011
                      wrote on last edited by
                      #22

                      im sori but i am using SQLDataSource thats why i have only one line of Code. I just bind the listbox on my textfield. I did not use the manual connection in code behind. Any idea about that?. I already check the multiple selection but still insert 1 data per transaction thank you Bernie

                      1 Reply Last reply
                      0
                      • C Chetan Ranpariya

                        HI, I have asked you to paste your whole code here. but I dont think you want to do that. You are just pasting one or two lines and want me to do everything for you. Things doesnt happen like that. If you want to insert values from the listbox the commong logic is that you take items from the listbox one by one and create insert query for each of the item and execute the query. foreach(ListItem LI in lstbox.Items) { string strquery = "Insert Into table Values ('" + ddl.SelectedValue + "', '" + LI.Value + "')"; cmd.executenonquery(strquery); } THis is the commong logic. You implement this as per your requirement. If any further assistance is needed then do reply with the whole code u have written to insert the data in the table. Thanks and Regards, Chetan Ranpariya

                        B Offline
                        B Offline
                        bernie_011
                        wrote on last edited by
                        #23

                        hi again, do you have any idea on how to create exam application in asp.net 2.0 web app? Bernie

                        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