Inserting multiple records into SQL database from asp.net C# cascade combobox

I have a page I need to modify.  The page was written by another developer.  The page already had a combobox and function that allowed the user to select an author's name, click a button, then add that author's name to their wish list.  I need to add a nother combobox that displays the library's genres, display the authors associated with that genre, then allow the user to click a button and add all those authors to their reading wish list.  Here is the code with both the author and the genre comboboxes and the script that I'm attempting to use to insert all the authors when a genre is selected:  

   
`        <asp:DropDownList ID="ddlGenres" runat="server" DataSourceID="SqlDataSourceLibros" 
            DataTextField="Genre_Name" DataValueField="GenreID" onselectedindexchanged="genreList_SelectedIndexChanged" 
            AutoPostBack="True" AppendDataBoundItems="true">
            <asp:ListItem Value="0">Groups</asp:ListItem>
             </asp:DropDownList>
             <asp:SqlDataSource ID="SqlDataSource1Libros" runat="server" 
            ConnectionString="<%$ ConnectionStrings:Libros %>" 
            SelectCommand="SELECT [GenreID],[Genre_Name] FROM [Library_Genres] ORDER BY [Genre_Name]">        
             </asp:SqlDataSource>
              <asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="True" 
            DataSourceID="SqlDataSourceLibros2" DataTextField="Author_Name"  EnableViewState="false"
            DataValueField="Genre_Name">
            </asp:DropDownList>
            <asp:ImageButton ImageUrl="~/buttons/addGenre.png" Height="18px"  OnMouseOver="this.src='../buttons/addGenreHover.png'" OnMouseOut="this.src='../buttons/addGenre.png'" ToolTip="Add Library Genre" runat="server"  ID="btnAddGenre"  OnClick="btnAddGenre_Click" />
           <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
            ConnectionString="<%$ ConnectionStrings:Libros %>"         
            SelectCommand="SELECT [Author_Name] FROM [Library_authors] WHERE ([Genre_Name] = @Genre_Name)">
            <SelectParameters>
                <asp:ControlParameter ControlID="ddlGroups" Name="Author_Name" 
                    PropertyName="SelectedValue" Type="String" />
            </SelectParameters>
            </asp:SqlDataSource>

Open in new window


 And now the script that is called by clickiing the buttons:
   

`      ` protected void btnAddAuthors(object sender, EventArgs e)
          {
            odsAuthors.Insert();
            AuthorList.ClearSelection();
            Response.Redirect(Request.Url.AbsoluteUri);
         }
           protected void btnAddGenre(object sender, EventArgs e)
        {
            SqlDataSourceLibros2.Insert();
            ddlGenres.ClearSelection();
            Response.Redirect(Request.Url.AbsoluteUri);
         }
      `

Open in new window


My problem is that when I click the Add Genres button, the event that adds the individual author fire and is inserted - not all of the authors that appear in the combo box - depending on what genre is selected.

How can I get the list of authors to be inserted into the database like the individual author is inserted into the database when the AddAuthors button is clicked?
programmherAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
I am confused about your problem description...

Are you looking for a cascading DropDownList implementation?
0
programmherAuthor Commented:
No, the cascading implementation is working.  The next step is to insert those selected records into a separate table by clicking the add genres button.
0
Bob LearnedCommented:
That sounds like an unusual request, that you would want all the items in the Author drop down to be saved to the database.  I would think that you would need to use a for loop, and get the value of each item in the drop down list, and save them yourself.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
programmherAuthor Commented:
The client wants all of the authors that are associated with the selected genre to be updated to the selected record.

I will research implementing a for loop using a c# call to the database.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.