469,657 Members | 1,825 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,657 developers. It's quick & easy.

Multiple selected Listbox in GridView

Language C#, Version ASP.Net 2.0


I have a GridView which is bound to a table which contains Restaurant information. In the Edit Row there is a Listbox (ListBox1) in the Food Type column, bound to a table containing the food types.

<asp:ListBox ID="ListBox1" runat="server" AppendDataBoundItems="True" DataSourceID="FoodTypes"
DataTextField="FoodType" DataValueField="FoodType" SelectedValue='<%# Bind("food_type") %>'>
<asp:ListItem Value="">(None)</asp:ListItem></asp:ListBox>

<asp:ObjectDataSource ID="FoodTypes" runat="server" OldValuesParameterFormatString="original_{0}"
SelectMethod="GetFoodTypes" TypeName="VLAdminDSTableAdapters.tblFOODTYPESTable Adapter">

The problem I'm having is that the SelectedValue property of the ListBox is bound to the food_type column in the Restaurant table, which contains a string of food types separated by commas (not a good idea, I know, but I'm having to work with an inherited database).

If I convert the food_type string into an array how can I use it to select multiple ListItems in the ListBox as it is created? I can't seem to refer to ListBox1 from the page's code behind.

Any ideas?
Sep 21 '06 #1
0 2840

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by bill yeager | last post: by
1 post views Thread by sab | last post: by
10 posts views Thread by ads | last post: by
9 posts views Thread by Bob Malcoprs | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.