Search code examples
c#asp.netlistviewdrop-down-menulistviewitem

Fill dropdown list in listview from another stored procedure


I have a listview that I take data source from one stored procedure (select * products) then within that Listview I have dropdown that I want to fill with another procedure that takes id of current product and return list of values for dropdown. But how can I call 2nd stored procedure ?

   <asp:ListView ID="listProducts" runat="server">
            <ItemTemplate>
                 <div class="productoverlay">
                    <div class="col-lg-4 proizvod">
                         <div class="product">
                             <div class="glow"></div>
                             <img src='<%# "../productimg/" + Eval("FileName")%>' />
                        </div>
                    </div>
                     <div class="col-lg-8 pushtop">
                          <h1><%# Eval("ProductName") %></h1>

                         <p>Description: </p>
                         <p><%# Eval("ProductDescription") %></p>

                         <p>Quantity <%#Eval("Unit") %>:</p><input type='number' id='numberinput' name='mynumber' value='1' />  

                                  <select runat="server" id="drpSubcat">
                                  <option>Values from another procedure</option>

</select>
                         <button type="button">Add to cart</button> 
                         </div>
                 </div>
            </ItemTemplate>
        </asp:ListView>

Solution

  • use an aspnet DropDwonList with an ObjectDataSource, instead the select tag

    like this: Dropdown list bound to object data source - how to update on a button click