473,394 Members | 1,932 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

ListBoX update

1
I have two list boxes where a user can make a selection click a add button within a wizard control and it add it to another listbox in the same wizard. My problem is the add goes fine the second listbox is updatedwith the new value. The problem is the listbox where the selection was made still contains the value that was just put in th first listbox. Both listbox gets the data from the db so the next time the program runs both boxes are updated and there are no duplicate values. Is there a way Update both listboxes from the db when the add button is clicked.(remember im using wizard control with listboxes)
I hope I explained this clearly.
heres the code for the add button control

Expand|Select|Wrap|Line Numbers
  1. for (count = 0; count < PracticeListBox.Items.Count; count++)
  2.         {
  3.             if (PracticeListBox.Items[count].Selected == true) 
  4.                 {
  5.                     //moves item from one practice listbox to the next
  6.                     AgencyPracticeListBox.Items.Add(PracticeListBox.Items[count].ToString());
  7.                     PracticeListBox.Items.Remove(PracticeListBox.Items[count].ToString());
  8.                     SqlCommand cmd = new SqlCommand(AddPracticeQuery , con); 
  9.                     cmd.Parameters.Add(new SqlParameter("@Sponsor_ID", SqlDbType.Int));
  10.                     cmd.Parameters["@Sponsor_ID"].Value = Sponsor_ID;
  11.                     cmd.Parameters.Add(new SqlParameter("@Practice_ID", SqlDbType.Int));
  12.                     cmd.Parameters["@Practice_ID"].Value = PracticeListBox.Items[count].Value;
  13.                     con.Open();
  14.  
  15.                 try
  16.                     {
  17.                         cmd.ExecuteNonQuery();
  18.                     }
  19.                 catch (SqlException err)
  20.                     {
  21.                       Response.Write(err.Message.ToString());
  22.                     }
  23.                 con.Close();
  24.                 ///
  25.                 ///MUST BE  REFRESH CONTROL INFO
  26.                 ///                
  27.                 //ViewState.Add("Wizpage",WizPage);
  28.                 //Server.Transfer("ModifySponsor.aspx"); (tried calling the page but then it would only end up on the beginning of the wiz step)
Mar 29 '07 #1
0 1045

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Marc | last post by:
Hi all, I can't figure this out. I want the ability to delete an item in a listbox and leave the window area blank, like it is when the listbox is first created and nothing selected. Right...
5
by: Bill | last post by:
I have have two list boxes. One is a listing of all possible variables. We'll call this listbox A. The other is a listing of all the selected variables. We'll call this listbox B. If a person...
4
by: N. Graves | last post by:
Hello... thank you for your time. I have a form that has a List box of equipotent records and a sub form that will show the data of the equipment select from the list box. Is it possible to...
9
by: Megan | last post by:
Hi- I'm creating a database of music bands with their cds and songs. I'm trying to program an SQL statement so that I can enter a string of text in a textbox, press the 'Enter' key, and have...
7
by: Grant Schenck | last post by:
Hello, I have a ListBox control on a form. I add members of a class to the Items collection. They show up and I can select them. The text shown is from my classes ToString override. Now,...
1
by: MrNobody | last post by:
Hi, I'm doing something where I add custom objects to a ListBox which have aToString() method overriden so it displays what I want. When adding instances of these custom objects to the ListBox I...
6
by: Mark | last post by:
Hello. I have a listbox whose rowsource is set to a saved query (call it "qry_customer_list.") When I add customers to my database, I call the listbox Requery method so that the listbox will...
4
by: Marcos Beccar Varela | GamaCom Argentina | last post by:
Hello Everyone. I need to use a gridview, that when I use the Update command one of the colums, instead of showing a textbox where the user can write, I need a combobox (listobx), where there are...
3
by: Kevin Walzer | last post by:
I'm trying to set the active item in a Tkinter listbox to my application's currently-defined default font. Here's how I get the fonts loaded into the listbox: ...
3
by: deejayquai | last post by:
Hello Simple one this I guess, but I'm quite stuck at the moment. I would like to update the records displayed in my listbox (lstStudents) using criteria selected from my combo (cboForm) in a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.