javascripting with web controls
-
Hi, You can do it like this. ListItem litem = new ListItem(); litem.Text = drp.SelectedText; litem.Value = drp.SelectedValue; lstbox.Items.Add(litem); The code above is the logic and you can implement in VB easily. Just syntax is the difference. Thanks and Regards, Chetan Ranpariya
How can i insert all the items in listbox into the database? multiple insert. I can get all the items but its just inserting 1 row in that category. drpcategory : Agent,Trainees drpNames : Bernie, Ray,Kirby,John,Beejay list1 : contains all the selected items on drpNames table1 : my table in my database my query now is INSERT INTO table1(Category,Name)VALUES(@category,@name) If list1box1 contains all the items from drpnames and i select "Agent" category on my drpcategory and i click the button insert, all the 4 items will be inserted in my database table(table1) on a single click. Can you help me with that? I am using detailsView and SQLdatasource Bernie Leynes
-
How can i insert all the items in listbox into the database? multiple insert. I can get all the items but its just inserting 1 row in that category. drpcategory : Agent,Trainees drpNames : Bernie, Ray,Kirby,John,Beejay list1 : contains all the selected items on drpNames table1 : my table in my database my query now is INSERT INTO table1(Category,Name)VALUES(@category,@name) If list1box1 contains all the items from drpnames and i select "Agent" category on my drpcategory and i click the button insert, all the 4 items will be inserted in my database table(table1) on a single click. Can you help me with that? I am using detailsView and SQLdatasource Bernie Leynes
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
-
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
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
-
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
HI, I am not getting you exact requirement. Can you pelase elaborate by giving an example? Thanks and Regards, Chetan Ranpariya
-
HI, I am not getting you exact requirement. Can you pelase elaborate by giving an example? Thanks and Regards, Chetan Ranpariya
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
-
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
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
-
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
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
-
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
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
-
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
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
-
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
I know you know how to do that man. Please help me.. Thanks and God Bless Bernie
-
I know you know how to do that man. Please help me.. Thanks and God Bless Bernie
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
-
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
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
-
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
hi again, do you have any idea on how to create exam application in asp.net 2.0 web app? Bernie