472,783 Members | 938 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,783 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 1895
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...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

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.