By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,992 Members | 934 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,992 IT Pros & Developers. It's quick & easy.

Multi-Value Listbox, ObjectDataSource and Passing Parameter

P: n/a
I have a ListBox server control named "lb_dates" with a SelectionMode of
"Multiple". The user can select multiple dates from the listbox.

I have ObjectDataSource named "ods_rfq" with a ControlParameter that has a
ControlID that points to "lb_dates". The PropertyName of the ControlParameter
is "SelectedValue".

The user selects two dates from the ListBox.

I am trying to pass BOTH selected values of the ListBox to a SelectMethod of
the ObjectDataSource.

For some reason, all I get passed to the SelectMethod is one of the two
values that the user selected in the ListBox?

In the SelectMethod, I have tried to define the parameter as both a String
and a ListBox but it appears that the ListBox values are being passed as a
string.

I have searched the Internet on this topic and didn't find a true answer.
Some guy hid the ListBox values in a Label field, then accessed that. I guess
I can do that but I would rather find a better solution, if there is one.

Could someone enlighten me as to how I can access both (or all) of the
selected items in the ListBox, rather than just one of them?

The code is below for reference.

ASPX Page
----------
<asp:ListBox ID="lb_dates" runat="server" Rows="3" SelectionMode="Multiple"
/><br />
....
<asp:ObjectDataSource ID="ods_rfq" runat="server"
SelectMethod="Get_RFQ_Data" TypeName="Intranet_Engine.RFQ_Class">
<SelectParameters>
<asp:ControlParameter ControlID="lb_dates" Name="dates"
Type="Object" PropertyName="SelectedValue" />
</SelectParameters>
</asp:ObjectDataSource>
ASPX.VB Page
------------
Public Class RFQ_Class

Public Function Get_RFQ_Data(ByVal dates As String) As DataTable
'THIS IS WHERE I WANT THE dates VARIABLE TO CONTAIN BOTH SELECTED
VALUES OF THE LISTBOX BUT I ALWAYS ONLY GET ONE.

Return DB.DataTable
End Function

End Class
Aug 19 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.