|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Multiselect List BoxI 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 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, steph***@hotmail.com (Steph) wrote: Show quoteHide quote >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 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").GetType.ToString <> "System.DBNull" Then Me.lbx_Comorb.Items.FindByValue(dt.Rows(0)("ComorbID")).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 Show quoteHide quote Marcie Jones <marciejo***@yahoo.com> wrote in message news:<ojs751lrt3f9c1cbra8ni9alam9sffki01@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, steph***@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 |
|||||||||||||||||||||||