I have a multiselect enabled listbox on the page that is populated from a SqlDataSource.
I have another DataSource that retrieves the selected items from the database.
I cannot for the life of me figure out how to set all of the selected items in the listbox.
I have figured out how to get the first item from the selected items sqldatasource, but I don't know how to set ALL of the items from the sqldatasource as selected.
Any help would be greatly appreciated. I have been working on this for 3 days now to no avail.
Here is my listbox, sqlqueries, and code:
I have another DataSource that retrieves the selected items from the database.
I cannot for the life of me figure out how to set all of the selected items in the listbox.
I have figured out how to get the first item from the selected items sqldatasource, but I don't know how to set ALL of the items from the sqldatasource as selected.
Any help would be greatly appreciated. I have been working on this for 3 days now to no avail.
Here is my listbox, sqlqueries, and code:
Code:
<telerik:RadListBox ID="Regions_RadListBox" runat="server" Width="200px"
SelectionMode="Multiple" Rows="3" TextMode="MultiLine" DataSortField="Region"
DataSourceID="Regions_SqlDataSource" DataTextField="Region"
DataValueField="RegionID" Height="60px">
</telerik:RadListBox>
Code:
<asp:SqlDataSource ID="Regions_SqlDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:SiteSqlServer %>"
SelectCommand="SELECT [RegionID], [Region] FROM [NC_CT_Regions]"></asp:SqlDataSource>
<asp:SqlDataSource ID="SelectedRegions_SqlDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:SiteSqlServer %>"
SelectCommand="SELECT PreferenceValue FROM NC_EmployeePreference WHERE PreferenceTypeID = '4' AND EmpID = @EmpID">
<SelectParameters>
<asp:QueryStringParameter Name="EmpID" QueryStringField="EmpID" />
</SelectParameters>
</asp:SqlDataSource>
Code:
Dim regionsSql As DataView = DirectCast(SelectedRegions_SqlDataSource.Select(DataSourceSelectArguments.Empty), DataView)
For Each regionsviewSql As DataRowView In regionsSql
If Not Page.IsPostBack And regionsviewSql("PreferenceValue").ToString <> "" Then
Regions_RadListBox.SelectedValue = regionsviewSql("PreferenceValue")
End If
Next
Comment