DataList inside a ListView - passing parameter

Posted on 2009-02-13
Last Modified: 2012-05-07
I have a DataList inside a ListView.  The ListView renders a list of products.  The nested DataList lists out a number of cooresponding options related to the product.  I have a SqlDataSource that selects product options based on product ID.  How can I get the DataList's datasource to get the corresponding product id as the select parameter?  
<asp:ListView ID="lvProducts" runat="server" DataSourceID="sqlProdByCat" 

                        ItemPlaceholderID="phImgProd" ondatabound="lvProducts_DataBound" 


                        onitemdatabound="lvProducts_ItemDataBound" DataKeyNames="PROD_ProdID">


                            <table cellpadding="0" cellspacing="0" border="0" width="0">


                                    <td><asp:PlaceHolder ID="phImgProd" runat="server"></asp:PlaceHolder></td>





                            <td><asp:ImageButton ID="imgProduct" runat="server" 

                                ImageUrl='<%#Bind("PROD_LgImg") %>' CommandName="Detail" 

                                CommandArgument='<%#Bind("PROD_ProdID") %>'/><br />                                

                            <div class="options" 

                                style="text-align: center;">

                                <asp:DataList ID="dlActions" runat="server" 


                                    RepeatLayout="Flow" RepeatDirection="Horizontal">


                                        <asp:LinkButton ID="lnkAction" runat="server" 

                                            Text='<%# Bind("ACTN_ActionDesc") %>' 

                                            CommandName="tab" CommandArgument='<%# String.Format("{0}&{1}", DataBinder.Eval(Container.DataItem, "PROD_ProdID").ToString(), DataBinder.Eval(Container.DataItem, "TABS_TabID").ToString()) %>'>



                                    <SeparatorTemplate>&nbsp;&nbsp;  </SeparatorTemplate>




Open in new window

Question by:centdevs
    LVL 18

    Expert Comment

    in the sqlActionsByProd datasource, set the product parameter has a control parameter and the ListView has the control.
    LVL 18

    Expert Comment

    instead, move the sqlActionsByProd datasource inside the <ItemTemplate> of the listview and set the parameter s default value using '<%#Eval("PROD_ProdID") %>'/

    LVL 18

    Accepted Solution


    Author Comment

    Do I have to do anything programmatically?  I am currently getting an error:

    "Databinding expressions are only supported on objects that have a DataBinding event. System.Web.UI.WebControls.Parameter does not have a DataBinding event."

    And if I switch the select parameter to a control parameter I get the same type of error.

    Author Comment

    I just needed to move the sql data source to inside the listview rather than the datalist and use the control parameter.  Thank you!!

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
    This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now