Sunday, July 12, 2009

How can I pass multiple lines of text from text box to list box using c#.net?

I would like to enter multiple e-mail id's in text box at a time and get it stored in listbox. I also have to void the email_id which is already in the listbox with out entering any duplicates. I am using a button control also i.e., if I enter the value in textbox and press the button I want it to be in list box.





Hope my question is clear!! Can any one help? Thanks in advance

How can I pass multiple lines of text from text box to list box using c#.net?
Basically, you'll need a global array that holds all the values you want stored in the listbox. You'll bind that listbox's values to the array.





Or, if you prefer, you could declare a global DataTable or similar data structure, and store the values for the listbox in that, to make things simpler, if you're more comfortable using ADO.





Your button control will call a function that picks up the global array (or DataTable). It examines all entries in the array (using foreach or a reader or similar) to see if the entry is already in the array.





If not, you'll push the choice onto the end of the array (or add a record to the DataTable), then rebind the listbox with the array (or DataTable).
Reply:check out http://www.pscode.com for great sample codes.


No comments:

Post a Comment