programmher
asked on
Why won't my multi select work?
My multi-select list box is not working. This is probably something simple. I am making sure that I hold the CTRL key before I select the authors' names, too.
Here is my code:
Here is my code:
<asp:DropDownList ID="listAuthors"
runat="server"
AppendDataBoundItems="True"
DataSourceID="Authors_ds"
DataTextField="Authorame"
SelectionMode="Multiple"
AutoPostBack = "true">
<asp:ListItem Text="Select Authors" Value="~Select Author~" />
</asp:DropDownList>
ASKER
13Shadow,
The DataTextField is supposed to be AuthorName.
I am unable to select more than one author's name at a time.
I can only select one author's name at a time.
So, if 25 authors are displayed, I want to be able to select more than one author's name.
The DataTextField is supposed to be AuthorName.
I am unable to select more than one author's name at a time.
I can only select one author's name at a time.
So, if 25 authors are displayed, I want to be able to select more than one author's name.
Take a look at this:
http://www.codeproject.com/Articles/18063/Multi-select-Dropdown-list-in-ASP-NET
http://www.codeproject.com/Articles/18063/Multi-select-Dropdown-list-in-ASP-NET
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I am trying to download the zip file but keep getting an error.
Do you have another link that I can use to download the example?
Aman, do you have a link to an example that uses list items?
Do you have another link that I can use to download the example?
Aman, do you have a link to an example that uses list items?
ASKER
Aman,
I changed my code to this:
This is my error: The 'DataSource' property cannot be set declaratively.
What I need to happen is that the user selects their genre from the first dropdown box (ex: Horror).
The second list box displays all the authors names the library has who have written Horror books. The users need to select one or more of the authors listed.
I changed my code to this:
<asp:DropDownList runat="server" ID="lbGenreList"
style="float:left;" DataSourceID="Genres"
DataTextField="AuthorName"
onselectedindexchanged="genreList_SelectedIndexChanged"
AutoPostBack="True" AppendDataBoundItems="true">
</asp:DropDownList>
<asp:ListBox runat="server"
DataSource="Authors_ds"
DataTextField ="AuthorName"
ID = "AuthorList"
SelectionMode="Multiple"
OnSelectedIndexChanged = "AuthorList_SelectedIndexChanged" />
This is my error: The 'DataSource' property cannot be set declaratively.
What I need to happen is that the user selects their genre from the first dropdown box (ex: Horror).
The second list box displays all the authors names the library has who have written Horror books. The users need to select one or more of the authors listed.
ASKER
I changed my listbox to this and it resolved the error:
Thank you for your help.
My last step is to get the selected author (or authors) to update into my database.
<asp:ListBox runat="server" ID="AuthorList" DataTextField="AuthorName"
DataValueField="AuthorName" DataSourceID="Authors" SelectionMode="Multiple"/>
Thank you for your help.
My last step is to get the selected author (or authors) to update into my database.
When you say it is not working what exactly is it not doing?