Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Listbox binding to datasource problem?

Reply
Thread Tools

Listbox binding to datasource problem?

 
 
Dickson
Guest
Posts: n/a
 
      10-25-2004
Need some help on listbox which bind to datasource. Here is what i did :-

Dim sql As String = "SELECT supp_code,supp_name FROM
tblSupplier"
Dim DA As SqlDataAdapter = New SqlDataAdapter(sql, conn_str)
Dim DS As New DataSet

DA.Fill(DS, "Supplier")

lbListSupplier.DataSource = DS.Tables("Supplier").DefaultView
lbListSupplier.DataTextField = "supp_name"
lbListSupplier.DataValueField = "supp_code"
lbListSupplier.DataBind()

My problem is how can I delete an item from the listbox or add an item into
the listbox since it was bind to a datasource.
I do not want to re-populate the listbox again by querying the database.

Another problem is since the listbox is bind to a datatable, is that any way
I can use function like CType to extract the data
bind to listbox and put into a datatable? Thanks.


 
Reply With Quote
 
 
 
 
Scott Mitchell [MVP]
Guest
Posts: n/a
 
      10-25-2004
Dickson wrote:
> My problem is how can I delete an item from the listbox or add an item into
> the listbox since it was bind to a datasource.
> I do not want to re-populate the listbox again by querying the database.


The DropDownList's Items property has methods like Add(), Insert(),
Remove(), and RemoveAt() that can be used to add/remove items from the DDL.

hth

--

Scott Mitchell

http://www.4GuysFromRolla.com

* When you think ASP.NET, think 4GuysFromRolla.com!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
binding datasource to dropdownlist control DesignerX ASP .Net 5 12-29-2008 10:57 PM
I set listbox.datasource to fileinfo() object, but no files appear in the listbox. COHENMARVIN ASP .Net 1 10-14-2005 08:19 PM
Binding to JNDI datasource - please help John Chambers Java 1 03-21-2005 11:50 PM
How can I use an array as the datasource of a ListBox ad ASP .Net 1 03-03-2005 09:01 PM
binding xml as datasource suzy ASP .Net 0 04-11-2004 05:51 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57