473,378 Members | 1,309 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,378 software developers and data experts.

Multiselect List Box

I have created a multiselect list box control (lbx_comorb) that is
populated from a datatable (dt_ptAdmission). The list box populates
now problem at all.

However the issue is when I load the webform, when there is already
admission data. I need the populated list box (lbx_comorb) to show the
items that were previously selected for this admission. The selected
comorb data is stored in another datatable (dt_ptComorb).

If anyone can help with this it'd be greatly appreciated.

Cheers
Nov 21 '05 #1
2 1936
Hi Steph,
Each Item in the ListBox has a Selected property, so loop through the
items you want to show as selected, and set the Selected property of
the corresponding ListBox item to True.

Marcie

On 6 Apr 2005 00:42:53 -0700, st******@hotmail.com (Steph) wrote:
I have created a multiselect list box control (lbx_comorb) that is
populated from a datatable (dt_ptAdmission). The list box populates
now problem at all.

However the issue is when I load the webform, when there is already
admission data. I need the populated list box (lbx_comorb) to show the
items that were previously selected for this admission. The selected
comorb data is stored in another datatable (dt_ptComorb).

If anyone can help with this it'd be greatly appreciated.

Cheers


Nov 21 '05 #2
Hi Marcie

Thanks for the quick response. I am just wondering how I would do
this.

Code to populate the list box is as follows:
Note: I am doing it this was as I have to load data for 20 different
drop down lists.

Dim objConn As New SqlConnection(strCS)
Dim objDS As New DataSet
Dim objDA As New SqlDataAdapter

Dim objCommand As New SqlCommand
objDA.SelectCommand = objCommand
objCommand.Connection = objConn
objCommand.CommandType = CommandType.Text

'Load Comorbidities details to list box
objCommand.CommandText = "usp_ref_Comorb"
objDA.Fill(objDS, "tbl_Clinical_Comorb")
Me.lbx_Comorb.DataSource = objDS
Me.lbx_Comorb.DataMember = "tbl_Comorb"
Me.lbx_Comorb.DataTextField = "ReferenceDescription"
Me.lbx_Comorb.DataValueField = "ReferenceID"
Me.lbx_Comorb.DataBind()
Me.lbx_Comorb.Items.FindByText("None").Selected = True

'Load Patient Comorbidities to datatable
objCommand.CommandText = "usp_Admis_Comorb '" & strAdmissionID & "'"
objDA.Fill(objDS, "dt_ptComorb")

'Load Seleceted values into comorb ListBox
If objDS.Tables("dt_ptComorb").Rows(0)("ComorbID").Ge tType.ToString <>
"System.DBNull" Then
Me.lbx_Comorb.Items.FindByValue(dt.Rows(0)("Comorb ID")).Selected
= True
End If

I'm not 100% sure how to loop through all the rows from the datatable
(dt_ptcomorb) to show the multiple selected values in the listbox.

Thanks again for your assistance
Marcie Jones <ma*********@yahoo.com> wrote in message news:<oj********************************@4ax.com>. ..
Hi Steph,
Each Item in the ListBox has a Selected property, so loop through the
items you want to show as selected, and set the Selected property of
the corresponding ListBox item to True.

Marcie

On 6 Apr 2005 00:42:53 -0700, st******@hotmail.com (Steph) wrote:
I have created a multiselect list box control (lbx_comorb) that is
populated from a datatable (dt_ptAdmission). The list box populates
now problem at all.

However the issue is when I load the webform, when there is already
admission data. I need the populated list box (lbx_comorb) to show the
items that were previously selected for this admission. The selected
comorb data is stored in another datatable (dt_ptComorb).

If anyone can help with this it'd be greatly appreciated.

Cheers

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Sally | last post by:
I have a simple multiselect listbox with a rowsorce of MemberID, MemberName, SendLetter. SendLetter is a Yes/No field. What is the code to set SendLetter to Yes when the user selects MemberName? I...
2
by: Cassie Pennington | last post by:
I am trying to write various items from a multiselect list box to an SQL statement to update a report, without success. SQL only appears to accept hard-coded data or control values from a form, not...
1
by: Danny | last post by:
I like the combo box because you can scroll through items nicely, but the list box just has the navigation where you can go up and down. I am trying to allow the user to multiselect items. With...
1
by: Jillian Cee | last post by:
I have a multiselect list box (simple). I need to find out how to get Access to recognise my multiple selections firstly (I believe) then I want these selections to go into a query so that I can...
1
by: tod4 | last post by:
Hi, My problem: I have query with value klient and product. On my form Im using multiselect box as filter of klient value. Now I would like to use second multiselect on this form for product...
6
by: ¿ Mahesh Kumar | last post by:
Hi groups, Control name : ListboxID (lstCertification), selection mode=mutliselect. On Pageload i'm assinging string lstSplit="1/3/6/8" of the previously selected listindex id's. Now on the...
3
by: John | last post by:
Hi I am using the following get the items from a multiselect list; Dim ctl As Control For Each ctl In Me.BatchInvoicesList.ItemsSelected Problem is that I am getting a 'Object not found...
1
by: Redbeard | last post by:
I am a newbie running Access 2003. A couple of weeks back a member named ADezil help me write a code that let a , MultiSelect Listboxs that run a Query on a Form (many thanks). I have used this...
5
by: erbrose | last post by:
Hey all, newbie to vb here. I've created a listbox (called lst_county) that gets populated from a Select * From Table in Oracle on load. I've set the MultiSelect to 2 -Extended. I've got some code...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...

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.